﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using netDxf;
using netDxf.Blocks;
using netDxf.Collections;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Objects;
using netDxf.Tables;
using netDxf.Units;
using Attribute = netDxf.Entities.Attribute;
using Image = netDxf.Entities.Image;
using Point = netDxf.Entities.Point;
using Trace = netDxf.Entities.Trace;
using System.Threading;

namespace TestDxfDocument
{
    class Knife_holder_with_cylindrical_handle
    {
        public static void cylindrical_handle(Dictionary<string, Object> data)    //圆柱柄刀夹
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层

            //基本参数
            double scale = 1; //放大系数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            double ctrap = Convert.ToDouble(data["ctrap"]) * scale;

            //赋值参数
            double d1 = Convert.ToDouble(data["d1"]) * scale;
            double l10 = Convert.ToDouble(data["l10"]) * scale;
            double d20 = Convert.ToDouble(data["d20"]) * scale;
            double l20 = Convert.ToDouble(data["l20"]) * scale;
            double b = Convert.ToDouble(data["b"]) * scale;
            double h = Convert.ToDouble(data["h"]) * scale;
            double d3 = Convert.ToDouble(data["d3"]) * scale;
            double d6 = Convert.ToDouble(data["d6"]) * scale;
            double f = Convert.ToDouble(data["f"]) * scale;
            double g = Convert.ToDouble(data["g"]) * scale;
            double h1 = Convert.ToDouble(data["h1"]) * scale;
            double h2 = Convert.ToDouble(data["h2"]) * scale;
            if (ctrap != 1 && ctrap != 2 && ctrap != 3 && ctrap <= 11)
            {
                h2 = Convert.ToDouble(data["h2"]) * scale;
            }
            double h3 = 16.92 * scale;
            if (ctrap != 1 && ctrap != 2 && ctrap != 3 && ctrap <= 11)
            {
                h3 = Convert.ToDouble(data["h3"]) * scale;
            }
            double l3 = Convert.ToDouble(data["l3"]) * scale;
            double l4 = Convert.ToDouble(data["l4"]) * scale;
            double l7 = Convert.ToDouble(data["l7"]) * scale;
            double r1 = Convert.ToDouble(data["r1"]) * scale;
            double d2 = Convert.ToDouble(data["d2"]) * scale;
            double l1 = Convert.ToDouble(data["l1"]) * scale;
            if (ctrap != 1 && ctrap != 2 && ctrap != 3 && ctrap <= 11)
            {
                l1 = Convert.ToDouble(data["l1"]) * scale;
            }
            double l2 = 60 * scale;
            if (ctrap != 1 && ctrap != 2 && ctrap != 3 && ctrap <= 11)
            {
                l2 = Convert.ToDouble(data["l2"]) * scale;
            }
            double a = Convert.ToDouble(data["a"]) * scale;
            double h4 = Convert.ToDouble(data["h4"]) * scale;
            double h5 = Convert.ToDouble(data["h5"]) * scale;
            double h6 = Convert.ToDouble(data["h6"]) * scale;
            double h7 = Convert.ToDouble(data["h7"]) * scale;
            double h8 = Convert.ToDouble(data["h8"]) * scale;
            double h9 = Convert.ToDouble(data["h9"]) * scale;
            double b1 = Convert.ToDouble(data["b1"]) * scale;
            double b2 = Convert.ToDouble(data["b2"]) * scale;
            double b4 = Convert.ToDouble(data["b4"]) * scale;
            double b5 = Convert.ToDouble(data["b5"]) * scale;
            double b6 = Convert.ToDouble(data["b6"]) * scale;
            if (ctrap == 8 || ctrap == 9 || ctrap == 10 || ctrap == 11)
            {
                b1 = Convert.ToDouble(data["b1"]) * scale;
                b2 = Convert.ToDouble(data["b2"]) * scale;
            }
            double b3 = Convert.ToDouble(data["b3"]) * scale;

            if (ctrap == 12 || ctrap == 14)//C1和C3
            {
                b1 = Convert.ToDouble(data["b1"]) * scale;
                b2 = Convert.ToDouble(data["b2"]) * scale;
                b3 = Convert.ToDouble(data["b3"]) * scale;
            }

            if (ctrap >= 12 && ctrap <= 15)
            {
                h3 = Convert.ToDouble(data["h3"]) * scale;
                h4 = Convert.ToDouble(data["h4"]) * scale;
                h5 = Convert.ToDouble(data["h5"]) * scale;
                h6 = Convert.ToDouble(data["h6"]) * scale;
                h7 = Convert.ToDouble(data["h7"]) * scale;
                h8 = Convert.ToDouble(data["h8"]) * scale;
                h9 = Convert.ToDouble(data["h9"]) * scale;
                l1 = Convert.ToDouble(data["l1"]) * scale;
                l2 = Convert.ToDouble(data["l2"]) * scale;
                a = Convert.ToDouble(data["a"]) * scale;
            }

            if (ctrap == 16 || ctrap == 17)
            {
                d1 = Convert.ToDouble(data["d1"]) * scale;
                h1 = Convert.ToDouble(data["h1"]) * scale;
                b1 = Convert.ToDouble(data["b1"]) * scale;
                b2 = Convert.ToDouble(data["b2"]) * scale;
                b3 = Convert.ToDouble(data["b3"]) * scale;
                b4 = Convert.ToDouble(data["b4"]) * scale;
                h2 = Convert.ToDouble(data["h2"]) * scale;
                h3 = Convert.ToDouble(data["h3"]) * scale;
                h4 = Convert.ToDouble(data["h4"]) * scale;
                h5 = Convert.ToDouble(data["h5"]) * scale;
                h6 = Convert.ToDouble(data["h6"]) * scale;
                h7 = Convert.ToDouble(data["h7"]) * scale;
                l1 = Convert.ToDouble(data["l1"]) * scale;
                l2 = Convert.ToDouble(data["l2"]) * scale;
                a = Convert.ToDouble(data["a"]) * scale;
            }


            //第一部分
            //中心线点
            Vector2 v3 = new Vector2(0, 0);
            Vector2 v4 = new Vector2(v3.X + d3 * 1.1, v3.Y);
            Vector2 v5 = new Vector2(v3.X + fun.CalDistance(v3, v4) / 2, v3.Y);
            Vector2 v1 = new Vector2(v5.X, v5.Y + fun.CalDistance(v3, v4) / 2);
            Vector2 v2 = new Vector2(v5.X, v5.Y - fun.CalDistance(v3, v4) / 2);
            //图形点
            Vector2 v6 = fun.Polar(v5, 135 * pi / 180, d3 / 6 - d3 / 36);
            Vector2 v7 = fun.mirrorpoint(v6, v1, v2);
            Vector2 v8 = new Vector2(v5.X + d3 / 2 * 1.1, v5.Y + d3 / 2 * 1.1);
            Vector2 v9 = fun.mirrorpoint(v8, v1, v2);
            Vector2 v10 = fun.mirrorpoint(v9, v3, v4);
            Vector2 v11 = fun.mirrorpoint(v8, v3, v4);
            Vector2 v5_1 = fun.Polar(v5, -45 * pi / 180, r1);

            //第二部分
            //中心线点
            Vector2 v12 = new Vector2(v4.X + d3 / 4, v4.Y);
            Vector2 v13 = new Vector2(v12.X + l10 * 2, v12.Y);
            if (ctrap == 2 || ctrap == 3)
            {
                v13 = new Vector2(v12.X + l10 * 3, v12.Y);
            }
            if (ctrap == 12 || ctrap == 13 || ctrap == 14 || ctrap == 15)
            {
                v13 = new Vector2(v12.X + l10 * 3.1, v12.Y);
            }

            //图形点
            Vector2 v14 = new Vector2(v12.X + fun.CalDistance(v12, v13) / 60, v9.Y);
            if (ctrap == 2 || ctrap == 3)
            {
                v14 = new Vector2(v12.X + fun.CalDistance(v12, v13) / 60, v12.Y + h / 2);
            }
            if (ctrap == 12 || ctrap == 13 || ctrap == 15)
            {
                v14 = new Vector2(v14.X + l2, v14.Y);
            }
            if (ctrap == 14 || ctrap == 15)
            {
                v14 = new Vector2(v14.X + l2, v12.Y + h7);
            }


            Vector2 v15 = new Vector2(v14.X + l10 * 2 / 3, v14.Y);
            if (ctrap == 2 || ctrap == 3 || ctrap == 6)
            {
                if (ctrap == 2)
                {
                    v15 = new Vector2(v14.X + l1, v14.Y);
                }

            }

            if (ctrap != 1 || ctrap != 2 || ctrap != 3 && ctrap <= 11)
            {
                v15 = new Vector2(v14.X + l2, v14.Y);
            }
            if (ctrap == 12 || ctrap == 13 || ctrap == 14 || ctrap == 15)
            {
                v15 = new Vector2(v14.X + (l1 - l2), v14.Y);
            }

            Vector2 v16 = new Vector2(v15.X, v15.Y - h1 / 10);
            Vector2 v17 = new Vector2(v16.X + 0.5, v16.Y);
            Vector2 v18 = new Vector2(v17.X, v17.Y - h2);
            if (ctrap != 1 || ctrap != 2 || ctrap != 3 && ctrap <= 15)
            {
                v18 = new Vector2(v16.X, v16.Y - h2 * 0.8);
            }
            if (ctrap == 16 || ctrap == 17)
            {
                v18 = new Vector2(5 + l2, h3 - h1);
            }
            Vector2 v19 = new Vector2(v18.X + l7, v18.Y);
            Vector2 v20 = new Vector2(v19.X, v19.Y - (h3 - h2));
            if (ctrap != 1 || ctrap != 2 || ctrap != 3 /*&& ctrap <= 11*/)
            {
                v20 = new Vector2(v19.X, v19.Y - Math.Abs(h3 - h2));
            }
            //齿
            Vector2 v21 = new Vector2(v20.X + (l20 - (l7 + l3 / 2)), v20.Y);
            if (ctrap != 1 || ctrap != 2 || ctrap != 3 /*&& ctrap <= 11*/)
            {
                v21 = new Vector2(v20.X + Math.Abs(l20 - (l7 + l3 / 2)), v20.Y);
            }
            Vector2 v22 = fun.Polar(v21, -45 * pi / 180, (h3 - h2));
            if (ctrap != 1 || ctrap != 2 || ctrap != 3 /*&& ctrap <= 11*/)
            {
                v22 = fun.Polar(v21, -45 * pi / 180, Math.Abs(h3 - h2));
            }
            Vector2 v23 = fun.Polar(v22, 45 * pi / 180, (h3 - h2));
            if (ctrap != 1 || ctrap != 2 || ctrap != 3 /*&& ctrap <= 11*/)
            {
                v23 = fun.Polar(v22, 45 * pi / 180, Math.Abs(h3 - h2));
            }

            Vector2 v24 = new Vector2(v23.X + (l20 - (l7 + l3 / 2)), v20.Y);
            Vector2 v25 = fun.Polar(v24, -45 * pi / 180, (h3 - h2));
            if (ctrap != 1 || ctrap != 2 || ctrap != 3 /*&& ctrap <= 11*/)
            {
                v25 = fun.Polar(v24, -45 * pi / 180, Math.Abs(h3 - h2));
            }
            Vector2 v26 = fun.Polar(v25, 45 * pi / 180, (h3 - h2));
            if (ctrap != 1 || ctrap != 2 || ctrap != 3 /*&& ctrap <= 11*/)
            {
                v26 = fun.Polar(v25, 45 * pi / 180, Math.Abs(h3 - h2));
            }

            Vector2 v27 = new Vector2(v26.X + (l20 - (l7 + l3 / 2)), v20.Y);
            Vector2 v28 = fun.Polar(v27, -45 * pi / 180, (h3 - h2));
            if (ctrap != 1 || ctrap != 2 || ctrap != 3/* && ctrap <= 11*/)
            {
                v28 = fun.Polar(v27, -45 * pi / 180, Math.Abs(h3 - h2));
            }
            Vector2 v29 = fun.Polar(v28, 45 * pi / 180, (h3 - h2));
            if (ctrap != 1 || ctrap != 2 || ctrap != 3 /*&& ctrap <= 11*/)
            {
                v29 = fun.Polar(v28, 45 * pi / 180, Math.Abs(h3 - h2));
            }

            Vector2 v30_1 = new Vector2(v29.X + (l20 - (l7 + l3 / 2)), v20.Y);
            Vector2 v30 = fun.Polar(v30_1, -45 * pi / 180, (h3 - h2));
            if (ctrap != 1 || ctrap != 2 || ctrap != 3 /*&& ctrap <= 11*/)
            {
                v30 = fun.Polar(v30_1, -45 * pi / 180, Math.Abs(h3 - h2));
            }
            Vector2 v31 = fun.Polar(v30, 45 * pi / 180, (h3 - h2));
            if (ctrap != 1 || ctrap != 2 || ctrap != 3 /*&& ctrap <= 11*/)
            {
                v31 = fun.Polar(v30, 45 * pi / 180, Math.Abs(h3 - h2));
            }

            Vector2 v32 = new Vector2(v31.X + (l20 - (l7 + l3 / 2)), v20.Y);
            Vector2 v33 = fun.Polar(v32, -45 * pi / 180, (h3 - h2));
            if (ctrap != 1 || ctrap != 2 || ctrap != 3 /*&& ctrap <= 11*/)
            {
                v33 = fun.Polar(v32, -45 * pi / 180, Math.Abs(h3 - h2));
            }
            Vector2 v34 = fun.Polar(v33, 45 * pi / 180, (h3 - h2));
            if (ctrap != 1 || ctrap != 2 || ctrap != 3 /*&& ctrap <= 11*/)
            {
                v34 = fun.Polar(v33, 45 * pi / 180, Math.Abs(h3 - h2));
            }

            Vector2 v35 = new Vector2(v34.X + (l20 - (l7 + l3 / 2)), v20.Y);
            Vector2 v36 = fun.Polar(v35, -45 * pi / 180, (h3 - h2));
            if (ctrap != 1 || ctrap != 2 || ctrap != 3 /*&& ctrap <= 11*/)
            {
                v36 = fun.Polar(v35, -45 * pi / 180, Math.Abs(h3 - h2));
            }
            Vector2 v37 = fun.Polar(v36, 45 * pi / 180, (h3 - h2));
            if (ctrap != 1 || ctrap != 2 || ctrap != 3 /*&& ctrap <= 11*/)
            {
                v37 = fun.Polar(v36, 45 * pi / 180, Math.Abs(h3 - h2));
            }

            Vector2 v38 = new Vector2(v18.X + l10, v37.Y);
            if (ctrap == 16 || ctrap == 17)
            {
                v38 = new Vector2(v18.X + l2, v37.Y);
            }
            Vector2 v39 = new Vector2(v38.X, v38.Y - h1);
            Vector2 v41 = new Vector2(v39.X - l10, v39.Y);
            Vector2 v42 = new Vector2(v41.X, v41.Y - l4);
            Vector2 v54 = fun.Polar(v42, -150 * pi / 180, 1);
            Vector2 v43 = new Vector2(v42.X, v54.Y - (d20 + fun.CalDistance(new Vector2(v42.X, v54.Y), v42)));
            Vector2 v44 = new Vector2(v43.X, v43.Y - l4);
            Vector2 v45 = new Vector2(v44.X - 0.5, v44.Y);
            Vector2 v46 = new Vector2(v45.X, v10.Y);

            if ((ctrap != 1 && ctrap != 2 && ctrap != 3) && ctrap <= 11)
            {
                v46 = new Vector2(v15.X, v12.Y - h8);
            }

            if (ctrap == 12 || ctrap == 13)
            {
                v46 = new Vector2(v15.X, v15.Y - (h5 + h8));
            }
            if (ctrap == 14 || ctrap == 15)
            {
                v46 = new Vector2(v15.X, v12.Y - h9);
            }

            Vector2 v47 = new Vector2(v14.X, -v14.Y);
            Vector2 v46f = new Vector2(v46.X, v47.Y);
            if (ctrap == 12 || ctrap == 13)
            {
                v46f = new Vector2(v46.X, v47.Y);
            }
            if (ctrap == 14 || ctrap == 15)
            {
                v46f = new Vector2(v46.X, v12.Y - h6);
            }
            Vector2 v46_1 = new Vector2(v46.X - (v46.Y - v46f.Y) / Math.Tan(a * pi / 180), v47.Y);
            if (ctrap == 14 || ctrap == 15)
            {
                v46_1 = new Vector2(v46.X - (v46.Y - v46f.Y) / Math.Tan(a * pi / 180), v12.Y - h6);
            }
            if (ctrap == 12 || ctrap == 13)
            {
                v47 = new Vector2(v14.X - l2, v46_1.Y);
            }
            if (ctrap == 14 || ctrap == 15)
            {
                v47 = new Vector2(v14.X - l2, v12.Y - h6);
            }
            Vector2 v48 = new Vector2(v47.X, -h1);
            if (ctrap == 12 || ctrap == 13 || ctrap == 14 || ctrap == 15)
            {
                v48 = new Vector2(v47.X, v12.Y - 2);
            }
            Vector2 v49 = new Vector2(v48.X + fun.CalDistance(v47, v46) / 2, v48.Y);
            if (ctrap != 1 || ctrap != 2 || ctrap != 3 && ctrap <= 11)
            {
                v49 = new Vector2(v48.X + (l2 - l1), v48.Y);
            }
            else
            {
                v49 = new Vector2(v48.X + (l2 - l1), v48.Y);
            }
            if (ctrap == 12 || ctrap == 13 || ctrap == 14 || ctrap == 15)
            {
                v49 = new Vector2(v14.X, v48.Y);
            }
            Vector2 v50 = new Vector2(v49.X, v12.Y + h1 / 3);
            if (ctrap != 1 || ctrap != 2 || ctrap != 3 && ctrap <= 11)
            {
                v50 = new Vector2(v49.X, v12.Y + (h2 - h1));
            }
            else
            {
                v50 = new Vector2(v49.X, v12.Y + (h2 - h1));
            }
            Vector2 v51 = new Vector2(v48.X, v50.Y);
            Vector2 v52 = new Vector2(v42.X - 8, v54.Y);
            Vector2 v53 = new Vector2(v52.X, v52.Y - d20);
            Vector2 v55 = new Vector2(v54.X, v54.Y - d20);

            //作图部分
            if (ctrap == 1)//刀夹的圆柱柄
            {
                //作图
                //第一部分
                //中心线
                Line centre_line1 = new Line(v1, v2);
                centre_line1.Layer = centre;
                centre_line1.Linetype = Linetype.Center;
                centre_line1.LinetypeScale = 5;
                dxf.AddEntity(centre_line1);

                Line centre_line2 = new Line(v3, v4);
                centre_line2.Layer = centre;
                centre_line2.Linetype = Linetype.Center;
                centre_line2.LinetypeScale = 5;
                dxf.AddEntity(centre_line2);

                //外圈虚线
                Line line1 = new Line(v8, v9);
                line1.Layer = refin;
                line1.Linetype = Linetype.Dashed;
                line1.LinetypeScale = 5;
                dxf.AddEntity(line1);

                Line line2 = new Line(v9, v10);
                line2.Layer = refin;
                line2.Linetype = Linetype.Dashed;
                line2.LinetypeScale = 5;
                dxf.AddEntity(line2);

                Line line3 = new Line(v10, v11);
                line3.Layer = refin;
                line3.Linetype = Linetype.Dashed;
                line3.LinetypeScale = 5;
                dxf.AddEntity(line3);

                Line line4 = new Line(v8, v11);
                line4.Layer = refin;
                line4.Linetype = Linetype.Dashed;
                line4.LinetypeScale = 5;
                dxf.AddEntity(line4);

                //作圆
                fun.drawcircle(dxf, v5, d3 / 2, 0.3, contour);
                fun.drawcircle(dxf, v5_1, r1 - d3 / 4, 0.3, contour);
                fun.drawcircle(dxf, v5, d3 / 2 / 3, 0.3, contour);

                //最内圈圆弧
                Vector2[] Line1 = { v6, v7 };
                fun.drawBLine(dxf, Line1, 0.3, contour);

                LwPolyline polyline1 = new LwPolyline();
                polyline1.Vertexes.Add(new LwPolylineVertex(v7));
                polyline1.Vertexes.Add(new LwPolylineVertex(v6));
                polyline1.Vertexes[0].Bulge = -Math.Tan((pi * 2 - (pi - fun.CalAngle(v5, v7) * 2)) / 4);
                fun.PolyFill(dxf, polyline1, 0.3, contour);

                //第二部分
                //中心线
                Line centre_line3 = new Line(v12, v13);
                centre_line3.Layer = centre;
                centre_line3.Linetype = Linetype.Center;
                centre_line3.LinetypeScale = 5;
                dxf.AddEntity(centre_line3);

                //作图
                LwPolyline polyline2 = new LwPolyline();
                polyline2.Vertexes.Add(new LwPolylineVertex(v16));
                polyline2.Vertexes.Add(new LwPolylineVertex(v17));
                polyline2.Vertexes.Add(new LwPolylineVertex(v18));
                polyline2.Vertexes.Add(new LwPolylineVertex(v19));
                polyline2.Vertexes.Add(new LwPolylineVertex(v20));
                polyline2.Vertexes.Add(new LwPolylineVertex(v21));
                polyline2.Vertexes.Add(new LwPolylineVertex(v22));
                polyline2.Vertexes.Add(new LwPolylineVertex(v23));
                polyline2.Vertexes.Add(new LwPolylineVertex(v24));
                polyline2.Vertexes.Add(new LwPolylineVertex(v25));
                polyline2.Vertexes.Add(new LwPolylineVertex(v26));
                polyline2.Vertexes.Add(new LwPolylineVertex(v27));
                polyline2.Vertexes.Add(new LwPolylineVertex(v28));
                polyline2.Vertexes.Add(new LwPolylineVertex(v29));
                polyline2.Vertexes.Add(new LwPolylineVertex(v30_1));
                polyline2.Vertexes.Add(new LwPolylineVertex(v30));
                polyline2.Vertexes.Add(new LwPolylineVertex(v31));
                polyline2.Vertexes.Add(new LwPolylineVertex(v32));
                polyline2.Vertexes.Add(new LwPolylineVertex(v33));
                polyline2.Vertexes.Add(new LwPolylineVertex(v34));
                polyline2.Vertexes.Add(new LwPolylineVertex(v35));
                polyline2.Vertexes.Add(new LwPolylineVertex(v36));
                polyline2.Vertexes.Add(new LwPolylineVertex(v37));
                polyline2.Vertexes.Add(new LwPolylineVertex(v38));
                polyline2.Vertexes.Add(new LwPolylineVertex(v39));
                polyline2.Vertexes.Add(new LwPolylineVertex(v41));
                polyline2.Vertexes.Add(new LwPolylineVertex(v44));
                polyline2.Vertexes.Add(new LwPolylineVertex(v45));
                fun.PolyFill(dxf, polyline2, 0.3, contour);

                Line line5 = new Line(v14, v15);
                line5.Layer = refin;
                line5.Linetype = Linetype.Dashed;
                line5.LinetypeScale = 5;
                dxf.AddEntity(line5);

                Vector2 p1 = fun.Inters(v15, new Vector2(v15.X, v15.Y - l10 * 2), v54, v42);
                Line line6 = new Line(v15, p1);
                line6.Layer = refin;
                line6.Linetype = Linetype.Dashed;
                line6.LinetypeScale = 5;
                dxf.AddEntity(line6);

                Line line7 = new Line(v45, v46);
                line7.Layer = refin;
                line7.Linetype = Linetype.Dashed;
                line7.LinetypeScale = 5;
                dxf.AddEntity(line7);

                Line line8 = new Line(v46, v47);
                line8.Layer = refin;
                line8.Linetype = Linetype.Dashed;
                line8.LinetypeScale = 5;
                dxf.AddEntity(line8);

                Line line9 = new Line(v47, v48);
                line9.Layer = refin;
                line9.Linetype = Linetype.Dashed;
                line9.LinetypeScale = 5;
                dxf.AddEntity(line9);

                Line line10 = new Line(v48, v49);
                line10.Layer = refin;
                line10.Linetype = Linetype.Dashed;
                line10.LinetypeScale = 5;
                dxf.AddEntity(line10);

                Line line11 = new Line(v49, v50);
                line11.Layer = refin;
                line11.Linetype = Linetype.Dashed;
                line11.LinetypeScale = 5;
                dxf.AddEntity(line11);

                Line line12 = new Line(v50, v51);
                line12.Layer = refin;
                line12.Linetype = Linetype.Dashed;
                line12.LinetypeScale = 5;
                dxf.AddEntity(line12);

                Line line13 = new Line(v51, v14);
                line13.Layer = refin;
                line13.Linetype = Linetype.Dashed;
                line13.LinetypeScale = 5;
                dxf.AddEntity(line13);

                LwPolyline polyline3 = new LwPolyline();
                polyline3.Vertexes.Add(new LwPolylineVertex(v42));
                polyline3.Vertexes.Add(new LwPolylineVertex(v54));
                polyline3.Vertexes.Add(new LwPolylineVertex(v52));
                polyline3.Vertexes.Add(new LwPolylineVertex(v53));
                polyline3.Vertexes.Add(new LwPolylineVertex(v55));
                polyline3.Vertexes.Add(new LwPolylineVertex(v43));
                fun.PolyFill(dxf, polyline3, 0.3, contour);

                Vector2[] Line3 = { v54, v55 };
                fun.drawBLine(dxf, Line3, 0.3, contour);

                //标注
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 1;
                dimensionStyle.ExtLineExtend = 0.6;//标注延长线长度/2
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;

                //文本样式
                dimensionStyle.TextHeight = 1 * scale;

                //第一部分
                fun.jdbz1(dxf, new Line(v6, new Vector2(v6.X - 0.1, v6.Y)), new Line(v6, fun.Polar(v6, 120 * pi / 180, 0.1)), 10, "60°±0°3'", 1);

                LinearDimension dim1 = new LinearDimension(new Line(fun.Polar(v5, -135 * pi / 180, d3 / 2), fun.Polar(v5, 45 * pi / 180, d3 / 2)), 0.1, -135, dimensionStyle);
                dim1.UserText = "φd3=" + Math.Round(d3 * scale, 1);
                dxf.AddEntity(dim1);

                //第二部分
                LinearDimension dim2 = new LinearDimension(new Line(v15, v17), h2, 0, dimensionStyle);
                dim2.UserText = "0.5";
                dxf.AddEntity(dim2);

                LinearDimension dim3 = new LinearDimension(new Line(v17, v29), h2 * 1.5, 0, dimensionStyle);
                dim3.UserText = "l2=" + Math.Round(l20 * scale, 1);
                dxf.AddEntity(dim3);

                LinearDimension dim4 = new LinearDimension(new Line(v21, v37), h2, 0, dimensionStyle);
                dim4.UserText = "l3=" + Math.Round(l3 * scale, 1);
                dxf.AddEntity(dim4);

                LinearDimension dim5 = new LinearDimension(new Line(v21, v29), h2 / 2, 0, dimensionStyle);
                dim5.UserText = "l3/2=" + Math.Round(l3 / 2 * scale, 1);
                dxf.AddEntity(dim5);

                LinearDimension dim6 = new LinearDimension(new Line(v32, v34), h2 / 3, 0, dimensionStyle);
                dim6.UserText = "φ3";
                dxf.AddEntity(dim6);

                LinearDimension dim7 = new LinearDimension(new Line(v17, v21), h2, 0, dimensionStyle);
                dim7.UserText = "l7=" + Math.Round(l7 * scale, 1);
                dxf.AddEntity(dim7);

                LinearDimension dim8 = new LinearDimension(new Line(v54, v55), l4 * 2, -90, dimensionStyle);
                dim8.UserText = "d2=" + Math.Round(d20 * scale, 1);
                dxf.AddEntity(dim8);

                LinearDimension dim9 = new LinearDimension(new Line(v38, v39), l4 * 2, -90, dimensionStyle);
                dim9.UserText = "h2=" + Math.Round(h2 * scale, 1);
                dxf.AddEntity(dim9);

                LinearDimension dim10 = new LinearDimension(new Line(v44, v39), h2, 180, dimensionStyle);
                dim10.UserText = "l1=" + Math.Round(l10 * scale, 1);
                dxf.AddEntity(dim10);

                LinearDimension dim11 = new LinearDimension(new Line(v53, v44), h2, 180, dimensionStyle);
                dim11.UserText = "8" + Math.Round(l7 * scale, 1);
                dxf.AddEntity(dim11);

                fun.jdbz1(dxf, new Line(v55, new Vector2(v55.X + 0.1, v55.Y)), new Line(v55, fun.Polar(v55, -30 * pi / 180, 0.1)), 10, "30°", 1);

            }

            if (ctrap == 2 || ctrap == 3)//A1型刀夹——长方形
            {
                //第一部分
                //点
                Vector2 v52_2 = new Vector2(v52.X - fun.CalDistance(v52, v53) / 2, v52.Y - fun.CalDistance(v52, v53) / 2);
                Vector2 p52 = new Vector2(v52_2.X - 1, v52_2.Y);
                Vector2 p52_1 = new Vector2(p52.X + fun.CalDistance(v52, v54) * 2, p52.Y);
                //填充点
                Vector2 t1 = fun.Polar(v42, pi, fun.CalDistance(v54, v52) * 2);
                Vector2 t2 = fun.Polar(t1, -105 * pi / 180, fun.CalDistance(v54, v55));
                Vector2 t3 = fun.Inters(t2, new Vector2(t2.X, t2.Y - h3), v46, v47);
                //虚线点
                Vector2 x1 = fun.Polar(v14, -45 * pi / 180, l7 * 2);
                Vector2 x2 = fun.Polar(x1, 0, l10 / 3);
                Vector2 x3 = fun.Polar(x2, -pi / 2, h2 / 2);
                Vector2 x4 = fun.Polar(x1, -pi / 2, h2 / 2);

                //第二部分
                //点
                Vector2 v56 = new Vector2(v13.X + l10, v13.Y);
                Vector2 v57 = new Vector2(v56.X + l10 * 2, v56.Y);
                Vector2 v60 = new Vector2(v56.X + fun.CalDistance(v56, v57) / 2, v56.Y);
                Vector2 v58 = new Vector2(v60.X, v60.Y + l10);
                Vector2 v59 = new Vector2(v60.X, v60.Y - l10);
                Vector2 v61 = new Vector2(v56.X + 1, v56.Y + h / 2);
                Vector2 v62 = fun.mirrorpoint(v61, v58, v59);
                Vector2 v63 = fun.mirrorpoint(v61, v56, v57);
                Vector2 v64 = fun.mirrorpoint(v62, v56, v57);
                Vector2 v65 = fun.Polar(v60, 120 * pi / 180, h2 / 2);
                Vector2 v66 = fun.Polar(v60, 60 * pi / 180, h2 / 2);

                //作图
                //第一部分
                //中心线
                Line centre_line1 = new Line(v12, v13);
                centre_line1.Layer = centre;
                centre_line1.Linetype = Linetype.Center;
                centre_line1.LinetypeScale = 5;
                dxf.AddEntity(centre_line1);

                //轮廓
                LwPolyline polyline1 = new LwPolyline();
                polyline1.Vertexes.Add(new LwPolylineVertex(v16));
                polyline1.Vertexes.Add(new LwPolylineVertex(v17));
                polyline1.Vertexes.Add(new LwPolylineVertex(v18));
                polyline1.Vertexes.Add(new LwPolylineVertex(v19));
                polyline1.Vertexes.Add(new LwPolylineVertex(v20));
                polyline1.Vertexes.Add(new LwPolylineVertex(v21));
                polyline1.Vertexes.Add(new LwPolylineVertex(v22));
                polyline1.Vertexes.Add(new LwPolylineVertex(v23));
                polyline1.Vertexes.Add(new LwPolylineVertex(v24));
                polyline1.Vertexes.Add(new LwPolylineVertex(v25));
                polyline1.Vertexes.Add(new LwPolylineVertex(v26));
                polyline1.Vertexes.Add(new LwPolylineVertex(v27));
                polyline1.Vertexes.Add(new LwPolylineVertex(v28));
                polyline1.Vertexes.Add(new LwPolylineVertex(v29));
                polyline1.Vertexes.Add(new LwPolylineVertex(v30_1));
                polyline1.Vertexes.Add(new LwPolylineVertex(v30));
                fun.PolyFill(dxf, polyline1, 0.3, contour);

                LwPolyline polyline2 = new LwPolyline();
                polyline2.Vertexes.Add(new LwPolylineVertex(v30));
                polyline2.Vertexes.Add(new LwPolylineVertex(v31));
                polyline2.Vertexes.Add(new LwPolylineVertex(v32));
                polyline2.Vertexes.Add(new LwPolylineVertex(v33));
                polyline2.Vertexes.Add(new LwPolylineVertex(v34));
                polyline2.Vertexes.Add(new LwPolylineVertex(v35));
                polyline2.Vertexes.Add(new LwPolylineVertex(v36));
                polyline2.Vertexes.Add(new LwPolylineVertex(v37));
                polyline2.Vertexes.Add(new LwPolylineVertex(v38));
                polyline2.Vertexes.Add(new LwPolylineVertex(v39));
                polyline2.Vertexes.Add(new LwPolylineVertex(v41));
                polyline2.Vertexes.Add(new LwPolylineVertex(v44));
                polyline2.Vertexes.Add(new LwPolylineVertex(v45));
                polyline2.Vertexes.Add(new LwPolylineVertex(v46));
                polyline2.Vertexes.Add(new LwPolylineVertex(v47));
                polyline2.Vertexes.Add(new LwPolylineVertex(v14));
                polyline2.Vertexes.Add(new LwPolylineVertex(v15));
                polyline2.Vertexes.Add(new LwPolylineVertex(v16));
                fun.PolyFill(dxf, polyline2, 0.3, contour);

                LwPolyline polyline3 = new LwPolyline();
                polyline3.Vertexes.Add(new LwPolylineVertex(v42));
                polyline3.Vertexes.Add(new LwPolylineVertex(v54));
                polyline3.Vertexes.Add(new LwPolylineVertex(v52));
                polyline3.Vertexes.Add(new LwPolylineVertex(v53));
                polyline3.Vertexes.Add(new LwPolylineVertex(v55));
                polyline3.Vertexes.Add(new LwPolylineVertex(v43));
                fun.PolyFill(dxf, polyline3, 0.3, contour);

                LwPolyline polyline4 = new LwPolyline();
                polyline4.Vertexes.Add(new LwPolylineVertex(v52));
                polyline4.Vertexes.Add(new LwPolylineVertex(v52_2));
                polyline4.Vertexes.Add(new LwPolylineVertex(v53));
                fun.PolyFill(dxf, polyline4, 0.3, contour);

                Vector2[] Line1 = { v54, v55 };
                fun.drawBLine(dxf, Line1, 0.3, contour);

                Vector2 p1 = fun.Inters(v15, new Vector2(v15.X, v15.Y - l10 * 2), v54, v42);
                Vector2[] Line2 = { v16, p1 };
                fun.drawBLine(dxf, Line2, 0.3, contour);

                Line xu1 = new Line(x1, x2);
                xu1.Linetype = Linetype.Dashed;
                xu1.LinetypeScale = 5;
                xu1.Layer = refin;
                dxf.AddEntity(xu1);

                Line xu2 = new Line(x2, x3);
                xu2.Linetype = Linetype.Dashed;
                xu2.LinetypeScale = 5;
                xu2.Layer = refin;
                dxf.AddEntity(xu2);

                Line xu3 = new Line(x3, x4);
                xu3.Linetype = Linetype.Dashed;
                xu3.LinetypeScale = 5;
                xu3.Layer = refin;
                dxf.AddEntity(xu3);

                Line xu4 = new Line(x4, x1);
                xu4.Linetype = Linetype.Dashed;
                xu4.LinetypeScale = 5;
                xu4.Layer = refin;
                dxf.AddEntity(xu4);

                //中心线
                Line line1 = new Line(v12, v13);
                line1.Layer = centre;
                line1.Linetype = Linetype.Center;
                line1.LinetypeScale = 5;
                dxf.AddEntity(line1);

                Line line2 = new Line(p52, p52_1);
                line2.Layer = centre;
                line2.Linetype = Linetype.Center;
                line2.LinetypeScale = 5;
                dxf.AddEntity(line2);

                //第二部分
                //中心线
                Line line3 = new Line(v56, v57);
                line3.Layer = centre;
                line3.Linetype = Linetype.Center;
                line3.LinetypeScale = 5;
                dxf.AddEntity(line3);

                Line line4 = new Line(v58, v59);
                line4.Layer = centre;
                line4.Linetype = Linetype.Center;
                line4.LinetypeScale = 5;
                dxf.AddEntity(line4);

                //轮廓
                if (ctrap == 2)
                {
                    LwPolyline polyline5 = new LwPolyline();
                    polyline5.Vertexes.Add(new LwPolylineVertex(v61));
                    polyline5.Vertexes.Add(new LwPolylineVertex(v62));
                    polyline5.Vertexes.Add(new LwPolylineVertex(v64));
                    polyline5.Vertexes.Add(new LwPolylineVertex(v63));
                    polyline5.Vertexes.Add(new LwPolylineVertex(v61));
                    fun.PolyFill(dxf, polyline5, 0.3, contour);
                }


                //虚线
                Circle circle1 = new Circle(v60, h2 / 2);
                circle1.Linetype = Linetype.Dashed;
                circle1.LinetypeScale = 5;
                circle1.Layer = refin;
                dxf.AddEntity(circle1);

                if (ctrap == 2)
                {
                    Circle circle2 = new Circle(v60, fun.CalDistance(v17, v44) / 2);
                    circle2.Linetype = Linetype.Dashed;
                    circle2.LinetypeScale = 5;
                    circle2.Layer = refin;
                    dxf.AddEntity(circle2);
                }

                if (ctrap == 3)
                {
                    Circle circle2 = new Circle(v60, d2 / 2);
                    circle2.Linetype = Linetype.Dashed;
                    circle2.LinetypeScale = 5;
                    circle2.Layer = refin;
                    dxf.AddEntity(circle2);
                }

                //填充
                LwPolyline polyline6 = new LwPolyline();
                polyline6.Vertexes.Add(new LwPolylineVertex(v42));
                polyline6.Vertexes.Add(new LwPolylineVertex(t1));//0
                polyline6.Vertexes.Add(new LwPolylineVertex(t2));//1
                polyline6.Vertexes.Add(new LwPolylineVertex(t3));//2
                polyline6.Vertexes[0].Bulge = Math.Tan(10 * pi / 180);
                polyline6.Vertexes[1].Bulge = -Math.Tan(10 * pi / 180);
                polyline6.Vertexes[2].Bulge = Math.Tan(10 * pi / 180);
                fun.PolyFill(dxf, polyline6, 0.1, additionalline);

                LwPolyline hatchpoly1 = new LwPolyline();
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v42));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(t1));//0
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(t2));//1
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(t3));//2
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v46));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v45));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v44));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v43));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v53));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(p52));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v52));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v54));
                hatchpoly1.Vertexes.Add(new LwPolylineVertex(v42));
                hatchpoly1.Vertexes[0].Bulge = Math.Tan(10 * pi / 180);
                hatchpoly1.Vertexes[1].Bulge = -Math.Tan(10 * pi / 180);
                hatchpoly1.Vertexes[2].Bulge = Math.Tan(10 * pi / 180);
                hatchpoly1.IsClosed = true;
                String[] htype1 = new String[100];
                Line[] hline1 = new Line[100];
                Arc[] harc1 = new Arc[100];
                int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
                for (int i = 0; i < hnumst1; i++)
                {
                    htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                    if (htype1[i] == "Line")
                    {
                        hline1[i] = (Line)hatchpoly1.Explode()[i];
                    }
                    if (htype1[i] == "Arc")
                    {
                        harc1[i] = (Arc)hatchpoly1.Explode()[i];
                    }
                }
                fun.hatchsub1(dxf, htype1, hnumst1, 45, 10, hline1, harc1, hatching);

                //标注
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 1;
                dimensionStyle.ExtLineExtend = 0.6;//标注延长线长度/2
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;

                //文本样式
                dimensionStyle.TextHeight = 1;

                //第一部分
                if (ctrap == 2)
                {
                    LinearDimension dim1 = new LinearDimension(new Line(v47, v44), h2 / 2, 180, dimensionStyle);
                    dim1.UserText = "l1=" + Math.Round(l1 * scale, 1);
                    dxf.AddEntity(dim1);
                }

                if (ctrap == 3)
                {
                    LinearDimension dim1 = new LinearDimension(new Line(v47, v44), h2 / 2, 180, dimensionStyle);
                    dim1.UserText = "l2=" + Math.Round(l2 * scale, 1);
                    dxf.AddEntity(dim1);
                }

                Line line5 = new Line(v39, new Vector2(v39.X + l7, v39.Y));
                line5.Layer = dimensioning;
                dxf.AddEntity(line5);
                fun.jt1(dxf, new Vector2(v39.X + l7 - 1, v39.Y), 90, h2 / 2, 1, "φd1", 2);
                fun.jt1(dxf, v21, 60, h2 / 2, 1, "b", 2);

                Vector2 xu = fun.Inters(x1, x3, x2, x4);
                Vector2 xu_1 = fun.Polar(xu, 45 * pi / 180, fun.CalDistance(x1, x2) * 2);
                Line line6 = new Line(xu, xu_1);
                line6.Layer = dimensioning;
                dxf.AddEntity(line6);
                Text text1 = new Text("a", xu_1, 2, 0);
                dxf.AddEntity(text1);

                //第二部分
                if (ctrap == 2)
                {
                    LinearDimension dim2 = new LinearDimension(new Line(v63, v64), h2 / 2, 180, dimensionStyle);
                    dim2.UserText = "b=" + Math.Round(b * scale, 1);
                    dxf.AddEntity(dim2);

                    LinearDimension dim3 = new LinearDimension(new Line(v62, v64), h2 / 2, -90, dimensionStyle);
                    dim3.UserText = "h=" + Math.Round(h * scale, 1);
                    dxf.AddEntity(dim3);
                }

                if (ctrap == 3)
                {
                    Vector2 v60_1 = fun.Polar(v60, pi, d2 / 2);
                    Vector2 v60_2 = fun.Polar(v60, 0, d2 / 2);
                    LinearDimension dim4 = new LinearDimension(new Line(v60_1, v60_2), h2 * 2, 180, dimensionStyle);
                    dim4.UserText = "φd2=" + Math.Round(d2 * scale, 1);
                    dxf.AddEntity(dim4);
                }

            }

            //19448.3-------------------------------------------------------------------------------------------------------------------------
            //B1
            //点
            //第一部分
            Vector2 n1 = new Vector2(v51.X, v51.Y - (h2 - h1) / 6);
            Vector2 n2 = new Vector2(v50.X - (h2 - h1) / 6, n1.Y);
            Vector2 n3 = new Vector2(n1.X, n1.Y - (h2 - h1) * 0.6);
            Vector2 n4 = new Vector2(n2.X, n2.Y - (h2 - h1) * 0.6);
            Vector2 n5 = new Vector2(v49.X, v49.Y + h1 * 0.8);
            Vector2 n6 = new Vector2(n5.X + l1, n5.Y);

            //第二部分
            Vector2 v67 = new Vector2(v13.X + l1 * 2, v13.Y);
            if (ctrap == 9 || ctrap == 11)
            {
                v67 = new Vector2(v13.X + l1 * 4, v13.Y);
            }
            if (ctrap == 12 || ctrap == 14)
            {
                v67 = new Vector2(v13.X + l1, v13.Y);
            }
            Vector2 v68 = new Vector2(v67.X + b1 * 1.5, v67.Y);
            if (ctrap == 13)
            {
                v68 = new Vector2(v13.X + l1, v13.Y);
                v67 = new Vector2(v68.X + b1 * 1.5, v68.Y);
            }
            Vector2 v69f = new Vector2(v67.X + 5, v67.Y + h5);
            if (ctrap == 12 || ctrap == 13 || ctrap == 14 || ctrap == 15)
            {
                v69f = new Vector2(v67.X + 5, v15.Y);
            }
            Vector2 v69 = new Vector2(v69f.X, v67.Y + h4);
            if (ctrap == 12 || ctrap == 13 || ctrap == 14 || ctrap == 15)
            {
                v69 = new Vector2(v67.X + 5, v67.Y + h4);
            }
            Vector2 v71 = new Vector2(v69.X + (b1 - b3), v67.Y + h5);
            if (ctrap == 12 || ctrap == 14 || ctrap == 15)
            {
                v71 = new Vector2(v69.X + b1, v69f.Y);
            }
            if (ctrap == 13)
            {
                v71 = new Vector2(v69.X + b4, v69f.Y);
            }
            Vector2 v72 = new Vector2(v71.X, v71.Y - h5 / 2);
            if (ctrap == 12 || ctrap == 13 || ctrap == 14 || ctrap == 15)
            {
                v72 = new Vector2(v71.X, v68.Y + (h2 - h1));
            }
            Vector2 v70 = fun.Inters(fun.Polar(v69, 15 * pi / 180, l1), v69, v71, new Vector2(v71.X - l1, v71.Y));
            Vector2 v75 = new Vector2(v71.X, v71.Y - h5 - 2);
            if (ctrap == 12 || ctrap == 14 || ctrap == 15)
            {
                v75 = new Vector2(v72.X - (b2 - b3), v68.Y - h1);
            }
            if (ctrap == 13)
            {
                v75 = new Vector2(v72.X - (b5 - b6), v68.Y - h1);
            }
            Vector2 v76 = new Vector2(v75.X + b3, v75.Y);
            if (ctrap == 12 || ctrap == 13 || ctrap == 14 || ctrap == 15)
            {
                v76 = new Vector2(v72.X, v75.Y);
            }
            Vector2 v77 = new Vector2(v76.X, v76.Y - h6 / 2);
            Vector2 v78 = new Vector2(v77.X, v68.Y - h6);
            Vector2 v80 = new Vector2(v69.X, v67.Y - h3);
            Vector2 v80f = new Vector2(v80.X, v67.Y - h6);
            Vector2 v79 = fun.Inters(v80, fun.Polar(v80, -15 * pi / 180, l1), v78, new Vector2(v78.X - l1, v78.Y));
            Vector2 v81 = fun.Inters(v77, new Vector2(v77.X - b1 - 1, v77.Y), v80, v69);
            if (ctrap == 12 || ctrap == 13 || ctrap == 14 || ctrap == 15)
            {
                v72 = new Vector2(v71.X, v68.Y + (h2 - h1));
                v76 = new Vector2(v72.X, v75.Y);
                v78 = new Vector2(v76.X, v46_1.Y);
            }
            Vector2 v82 = fun.Inters(v72, new Vector2(v72.X - b1 - 1, v72.Y), v69, v80);
            if (ctrap == 12 || ctrap == 13 || ctrap == 14 || ctrap == 15)
            {
                v82 = fun.Inters(v70, new Vector2(v70.X, v70.Y - l1 * 2), v80, v79);
            }
            Vector2 v73 = new Vector2(v72.X, v72.Y - h5 / 8);
            if (ctrap == 12)
            {
                v73 = new Vector2(v72.X - (b2 - b3), v72.Y);
            }
            if (ctrap == 13)
            {
                v73 = new Vector2(v72.X - (b5 - b6), v72.Y);
            }
            if (ctrap == 14 || ctrap == 15)
            {
                v73 = new Vector2(v72.X - (b2 - b3), v72.Y);
            }
            Vector2 v83 = new Vector2(v73.X - (b1 - b3) + 2, v73.Y);
            Vector2 v84 = new Vector2(v83.X, v83.Y - h5 / 2 / 2);
            Vector2 v74 = fun.Inters(v84, new Vector2(v84.X + b1 + 1, v84.Y), v75, v71);
            Vector2 v87 = new Vector2(v76.X - b2, v68.Y);
            if (ctrap == 12 || ctrap == 14 || ctrap == 15)
            {
                v87 = new Vector2(v71.X - b2, v68.Y);
            }
            if (ctrap == 13)
            {
                v87 = new Vector2(v71.X - b5, v68.Y);
            }
            Vector2 v85 = new Vector2(v87.X, v87.Y + fun.CalDistance(v67, v68) / 2);
            Vector2 v86 = fun.mirrorpoint(v85, v67, v68);
            Vector2 v88 = fun.Polar(v87, -125 * pi / 180, h6 * 0.7);

            if (ctrap == 12 || ctrap == 13 || ctrap == 14 || ctrap == 15)
            {
                v83 = new Vector2(v72.X, v72.Y - (h2 - h1) / 4);
                v84 = new Vector2(v83.X, v68.Y + (h2 - h1) / 4);
            }

            if (ctrap == 5 || ctrap == 9)
            {
                v88 = fun.mirrorpoint(v88, v85, v86);
                v82 = fun.mirrorpoint(v82, v85, v86);
                v72 = fun.mirrorpoint(v72, v85, v86);
                v81 = fun.mirrorpoint(v81, v85, v86);
                v77 = fun.mirrorpoint(v77, v85, v86);
                v68 = fun.mirrorpoint(v68, v85, v86);
                v67 = fun.mirrorpoint(v67, v85, v86);
            }

            if (ctrap == 6 || ctrap == 10)
            {
                n5 = fun.mirrorpoint(n5, v12, v13);
                n6 = fun.mirrorpoint(n6, v12, v13);
                v82 = fun.mirrorpoint(v82, v67, v68);
                v72 = fun.mirrorpoint(v72, v67, v68);
                v81 = fun.mirrorpoint(v81, v67, v68);
                v77 = fun.mirrorpoint(v77, v67, v68);
            }

            if (ctrap == 7 || ctrap == 11)
            {
                n5 = fun.mirrorpoint(n5, v12, v13);
                n6 = fun.mirrorpoint(n6, v12, v13);
                v82 = fun.mirrorpoint(v82, v67, v68);
                v72 = fun.mirrorpoint(v72, v67, v68);
                v81 = fun.mirrorpoint(v81, v67, v68);
                v77 = fun.mirrorpoint(v77, v67, v68);
                v82 = fun.mirrorpoint(v82, v85, v86);
                v72 = fun.mirrorpoint(v72, v85, v86);
                v81 = fun.mirrorpoint(v81, v85, v86);
                v77 = fun.mirrorpoint(v77, v85, v86);
                v67 = fun.mirrorpoint(v67, v85, v86);
                v68 = fun.mirrorpoint(v68, v85, v86);
            }

            //B1型(4)，B2型(5),B3型(6),B4型(7)
            if (ctrap >= 4 && ctrap <= 11)
            {
                //中心线
                //第一部分
                Line centre_line3 = new Line(v12, v13);
                centre_line3.Layer = centre;
                centre_line3.Linetype = Linetype.Center;
                centre_line3.LinetypeScale = 5;
                dxf.AddEntity(centre_line3);
                //第二部分
                Line centre_line4 = new Line(v67, v68);
                centre_line4.Layer = centre;
                centre_line4.Linetype = Linetype.Center;
                centre_line4.LinetypeScale = 5;
                dxf.AddEntity(centre_line4);
                Line centre_line5 = new Line(v85, v86);
                centre_line5.Layer = centre;
                centre_line5.Linetype = Linetype.Center;
                centre_line5.LinetypeScale = 5;
                dxf.AddEntity(centre_line5);

                //作图
                //第一部分
                Vector2[] Line1 = { n5, n6 };
                fun.drawBLine(dxf, Line1, 0.3, contour);

                LwPolyline polyline1 = new LwPolyline();
                polyline1.Vertexes.Add(new LwPolylineVertex(v14));
                polyline1.Vertexes.Add(new LwPolylineVertex(v15));
                polyline1.Vertexes.Add(new LwPolylineVertex(v46));
                polyline1.Vertexes.Add(new LwPolylineVertex(v46_1));
                polyline1.Vertexes.Add(new LwPolylineVertex(v47));
                polyline1.Vertexes.Add(new LwPolylineVertex(v48));
                polyline1.Vertexes.Add(new LwPolylineVertex(v49));
                polyline1.Vertexes.Add(new LwPolylineVertex(v50));
                polyline1.Vertexes.Add(new LwPolylineVertex(v51));
                polyline1.Vertexes.Add(new LwPolylineVertex(v14));
                if (ctrap == 6 || ctrap == 7 || ctrap == 10 || ctrap == 11)
                {
                    polyline1 = Pus.MirrorPolyline(polyline1, v12, v13);
                    v14 = polyline1.Vertexes[0].Position;
                    v15 = polyline1.Vertexes[1].Position;
                    v46 = polyline1.Vertexes[2].Position;
                    v46_1 = polyline1.Vertexes[3].Position;
                    v47 = polyline1.Vertexes[4].Position;
                    v48 = polyline1.Vertexes[5].Position;
                    v49 = polyline1.Vertexes[6].Position;
                    v50 = polyline1.Vertexes[7].Position;
                    v51 = polyline1.Vertexes[8].Position;
                }
                fun.PolyFill(dxf, polyline1, 0.3, contour);

                LwPolyline polyline2 = new LwPolyline();
                polyline2.Vertexes.Add(new LwPolylineVertex(v18));
                polyline2.Vertexes.Add(new LwPolylineVertex(v19));
                polyline2.Vertexes.Add(new LwPolylineVertex(v20));
                polyline2.Vertexes.Add(new LwPolylineVertex(v21));
                polyline2.Vertexes.Add(new LwPolylineVertex(v22));
                polyline2.Vertexes.Add(new LwPolylineVertex(v23));
                polyline2.Vertexes.Add(new LwPolylineVertex(v24));
                polyline2.Vertexes.Add(new LwPolylineVertex(v25));
                polyline2.Vertexes.Add(new LwPolylineVertex(v26));
                polyline2.Vertexes.Add(new LwPolylineVertex(v27));
                polyline2.Vertexes.Add(new LwPolylineVertex(v28));
                polyline2.Vertexes.Add(new LwPolylineVertex(v29));
                polyline2.Vertexes.Add(new LwPolylineVertex(v30_1));
                polyline2.Vertexes.Add(new LwPolylineVertex(v30));
                polyline2.Vertexes.Add(new LwPolylineVertex(v31));
                polyline2.Vertexes.Add(new LwPolylineVertex(v32));
                polyline2.Vertexes.Add(new LwPolylineVertex(v33));
                polyline2.Vertexes.Add(new LwPolylineVertex(v34));
                polyline2.Vertexes.Add(new LwPolylineVertex(v35));
                polyline2.Vertexes.Add(new LwPolylineVertex(v36));
                polyline2.Vertexes.Add(new LwPolylineVertex(v37));
                polyline2.Vertexes.Add(new LwPolylineVertex(v38));
                polyline2.Vertexes.Add(new LwPolylineVertex(v39));
                polyline2.Vertexes.Add(new LwPolylineVertex(v41));
                fun.PolyFill(dxf, polyline2, 0.3, contour);

                LwPolyline polyline3 = new LwPolyline();
                polyline3.Vertexes.Add(new LwPolylineVertex(n1));
                polyline3.Vertexes.Add(new LwPolylineVertex(n2));
                polyline3.Vertexes.Add(new LwPolylineVertex(n4));
                polyline3.Vertexes.Add(new LwPolylineVertex(n3));
                polyline3.Vertexes.Add(new LwPolylineVertex(n1));
                if (ctrap == 6 || ctrap == 7 || ctrap == 10 || ctrap == 11)
                {
                    polyline3 = Pus.MirrorPolyline(polyline3, v12, v13);
                    n1 = polyline3.Vertexes[0].Position;
                    n2 = polyline3.Vertexes[1].Position;
                    n4 = polyline3.Vertexes[2].Position;
                    n3 = polyline3.Vertexes[3].Position;
                }
                fun.PolyFill(dxf, polyline3, 0.3, contour);

                //第二部分
                //轮廓
                LwPolyline polyline4 = new LwPolyline();
                polyline4.Vertexes.Add(new LwPolylineVertex(v69));
                polyline4.Vertexes.Add(new LwPolylineVertex(v70));
                polyline4.Vertexes.Add(new LwPolylineVertex(v71));
                polyline4.Vertexes.Add(new LwPolylineVertex(v75));
                polyline4.Vertexes.Add(new LwPolylineVertex(v76));
                polyline4.Vertexes.Add(new LwPolylineVertex(v78));
                polyline4.Vertexes.Add(new LwPolylineVertex(v79));
                polyline4.Vertexes.Add(new LwPolylineVertex(v80));
                polyline4.Vertexes.Add(new LwPolylineVertex(v69));
                if (ctrap == 5 || ctrap == 9)
                {
                    polyline4 = Pus.MirrorPolyline(polyline4, v85, v86);
                    v69 = polyline4.Vertexes[0].Position;
                    v70 = polyline4.Vertexes[1].Position;
                    v71 = polyline4.Vertexes[2].Position;
                    v75 = polyline4.Vertexes[3].Position;
                    v76 = polyline4.Vertexes[4].Position;
                    v78 = polyline4.Vertexes[5].Position;
                    v79 = polyline4.Vertexes[6].Position;
                    v80 = polyline4.Vertexes[7].Position;
                }
                if (ctrap == 6 || ctrap == 7 || ctrap == 10 || ctrap == 11)
                {
                    polyline4 = Pus.MirrorPolyline(polyline4, v67, v68);
                    if (ctrap == 7 || ctrap == 11)
                    {
                        polyline4 = Pus.MirrorPolyline(polyline4, v85, v86);
                    }
                    v69 = polyline4.Vertexes[0].Position;
                    v70 = polyline4.Vertexes[1].Position;
                    v71 = polyline4.Vertexes[2].Position;
                    v75 = polyline4.Vertexes[3].Position;
                    v76 = polyline4.Vertexes[4].Position;
                    v78 = polyline4.Vertexes[5].Position;
                    v79 = polyline4.Vertexes[6].Position;
                    v80 = polyline4.Vertexes[7].Position;
                }
                fun.PolyFill(dxf, polyline4, 0.3, contour);

                LwPolyline polyline5 = new LwPolyline();
                polyline5.Vertexes.Add(new LwPolylineVertex(v73));
                polyline5.Vertexes.Add(new LwPolylineVertex(v83));
                polyline5.Vertexes.Add(new LwPolylineVertex(v84));
                polyline5.Vertexes.Add(new LwPolylineVertex(v74));
                if (ctrap == 5 || ctrap == 9)
                {
                    polyline5 = Pus.MirrorPolyline(polyline5, v85, v86);
                    v73 = polyline5.Vertexes[0].Position;
                    v83 = polyline5.Vertexes[1].Position;
                    v84 = polyline5.Vertexes[2].Position;
                    v74 = polyline5.Vertexes[3].Position;
                }
                if (ctrap == 6 || ctrap == 7 || ctrap == 10 || ctrap == 11)
                {
                    polyline5 = Pus.MirrorPolyline(polyline5, v67, v68);
                    if (ctrap == 7 || ctrap == 11)
                    {
                        polyline5 = Pus.MirrorPolyline(polyline5, v85, v86);
                    }
                    v73 = polyline5.Vertexes[0].Position;
                    v83 = polyline5.Vertexes[1].Position;
                    v84 = polyline5.Vertexes[2].Position;
                    v74 = polyline5.Vertexes[3].Position;
                }
                fun.PolyFill(dxf, polyline5, 0.3, contour);

                Vector2[] Line2 = { v72, v82 };
                fun.drawBLine(dxf, Line2, 0.3, contour);

                Vector2[] Line3 = { v77, v81 };
                fun.drawBLine(dxf, Line3, 0.3, contour);

                //虚线
                Circle circle1 = new Circle(v87, fun.CalDistance(v38, v39) / 2);
                circle1.Layer = refin;
                circle1.Linetype = Linetype.Dashed;
                circle1.LinetypeScale = 5;
                dxf.AddEntity(circle1);

                Circle circle2 = new Circle(v88, fun.CalDistance(v38, v39) / 4);
                circle2.Layer = refin;
                circle2.Linetype = Linetype.Dashed;
                circle2.LinetypeScale = 5;
                dxf.AddEntity(circle2);

                Line line1 = new Line(v87, v88);
                line1.Layer = refin;
                line1.Linetype = Linetype.Dashed;
                line1.LinetypeScale = 5;
                dxf.AddEntity(line1);

                //标注
                //第一部分
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 1;
                dimensionStyle.ExtLineExtend = 0.6;//标注延长线长度/2
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;

                //文本样式
                dimensionStyle.TextHeight = 1;

                double height = 2;
                double arrowsize = 1;
                double exline = 2;

                //第一部分
                //直线标注
                if (ctrap == 4 || ctrap == 5 || ctrap == 8 || ctrap == 9)
                {
                    fun.dimrot1(dxf, v14, v15, 0, h2 / 2, 1, height, arrowsize, exline, "l2=" + Math.Round(l2, 1), "", "");
                    fun.dimrot1(dxf, v50, v15, 0, h2 / 1.5, 1, height, arrowsize, exline, "l1=" + Math.Round(l1, 1), "", "");
                    fun.dimrot1(dxf, v51, v48, 90, l1, 1, height, arrowsize, exline, "h2=" + Math.Round(h2, 1), "", "");
                    fun.dimrot1(dxf, v48, v12, 90, l1 / 2, 1, height, arrowsize, exline, "h1=" + Math.Round(h1, 1), "", "");
                    fun.dimrot1(dxf, v46, new Vector2(v46.X, v48.Y + h1), 90, l1 / 4, 1, height, arrowsize, exline, "h8=" + Math.Round(h8, 1), "", "");

                    Line line5 = new Line(v39, new Vector2(v39.X + l7, v39.Y));
                    line5.Layer = dimensioning;
                    dxf.AddEntity(line5);
                    fun.jt1(dxf, new Vector2(v39.X + l7 - 1, v39.Y), 90, h2 / 2, 1, "φd1=" + Math.Round(d1, 1), 2);
                    fun.jt1(dxf, v21, 60, h2 / 2, 1, "a=" + Math.Round(b, 1), 2);

                    //角度标注
                    fun.jdbz1(dxf, new Line(v46_1, new Vector2(v46_1.X + 0.1, v46_1.Y)), new Line(v46, fun.Polar(v46, a * pi / 180, 0.1)), 20, "α=" + a, height);
                }

                if (ctrap == 6 || ctrap == 7 || ctrap == 10 || ctrap == 11)
                {
                    fun.dimrot1(dxf, v47, v46, 0, h2 * 0.8, 1, height, arrowsize, exline, "l2=" + Math.Round(l2, 1), "", "");
                    fun.dimrot1(dxf, v49, v46, 0, h2 / 1.5, 1, height, arrowsize, exline, "l1=" + Math.Round(l1, 1), "", "");
                    fun.dimrot1(dxf, v51, v48, 90, l1, 1, height, arrowsize, exline, "h2=" + Math.Round(h2, 1), "", "");
                    fun.dimrot1(dxf, v48, v12, 90, l1 / 2, 1, height, arrowsize, exline, "h1=" + Math.Round(h1, 1), "", "");
                    fun.dimrot1(dxf, v46, new Vector2(v46.X, v12.Y), 90, l1 / 4, 1, height, arrowsize, exline, "h9=" + Math.Round(h8, 1), "", "");

                    Line line5 = new Line(v39, new Vector2(v39.X + l7, v39.Y));
                    line5.Layer = dimensioning;
                    dxf.AddEntity(line5);
                    fun.jt1(dxf, new Vector2(v39.X + l7 - 1, v39.Y), 90, h2 / 2, 1, "φd1=" + Math.Round(d1, 1), 2);
                    fun.jt1(dxf, v21, 60, h2 / 2, 1, "a=" + Math.Round(b, 1), 2);

                    //角度标注
                    fun.jdbz1(dxf, new Line(v46_1, new Vector2(v46_1.X + 0.1, v46_1.Y)), new Line(v46, fun.Polar(v46, -a * pi / 180, 0.1)), 10, "α=" + a, height);
                }

                //第二部分
                //直线标注
                if (ctrap == 4 || ctrap == 5 || ctrap == 8 || ctrap == 9)
                {
                    fun.dimrot1(dxf, v69, v76, 0, h5 * 1.5, 1, height, arrowsize, exline, "b1=" + Math.Round(b1, 1), "", "");
                    fun.dimrot1(dxf, v87, v76, 0, h5 * 1.5, 1, height, arrowsize, exline, "b2=" + Math.Round(b2, 1), "", "");
                    fun.dimrot1(dxf, v71, v76, 0, h5 * 0.7, 1, height, arrowsize, exline, "b3=" + Math.Round(b3, 1), "", "");
                }

                if (ctrap == 6 || ctrap == 7 || ctrap == 10 || ctrap == 11)
                {
                    fun.dimrot1(dxf, v69, v76, 180, h5 * 1.5, 1, height, arrowsize, exline, "b1=" + Math.Round(b1, 1), "", "");
                    fun.dimrot1(dxf, v87, v76, 180, h5 * 1.5, 1, height, arrowsize, exline, "b2=" + Math.Round(b2, 1), "", "");
                    fun.dimrot1(dxf, v71, v76, 180, h5 * 0.7, 1, height, arrowsize, exline, "b3=" + Math.Round(b3, 1), "", "");
                }

                if (ctrap == 4 || ctrap == 6 || ctrap == 8 || ctrap == 10)
                {
                    fun.dimrot1(dxf, v71, v68, -90, b2 / 2.0, 1, height, arrowsize, exline, "h5=" + Math.Round(h5, 1), "", "");
                    fun.dimrot1(dxf, v76, v68, -90, b2 / 3 / 2.0, 1, height, 0.5, exline, "2", "", "");
                    fun.dimrot1(dxf, v78, v68, -90, b2 * 0.9 * 0.5, 1, height, arrowsize, exline, "h6=" + Math.Round(h6, 1), "", "");
                    fun.dimrot1(dxf, v69, v67, 90, b2 * 0.4, 1, height, arrowsize, exline, "h3=" + Math.Round(h4, 1), "", "");
                    fun.dimrot1(dxf, v80, v67, 90, b2 * 0.4, 1, height, arrowsize, exline, "h4=" + Math.Round(h3, 1), "", "");
                }

                if (ctrap == 5 || ctrap == 9)
                {
                    fun.dimrot1(dxf, v71, v68, 90, b2 * 0.5, 1, height, arrowsize, exline, "h5=" + Math.Round(h5, 1), "", "");
                    fun.dimrot1(dxf, v76, v68, 90, b2 / 6, 1, height, 0.5, exline, "2", "", "");
                    fun.dimrot1(dxf, v78, v68, 90, b2 * 0.9 * 0.5, 1, height, arrowsize, exline, "h6=" + Math.Round(h6, 1), "", "");
                    fun.dimrot1(dxf, v69, v67, -90, b2 * 0.4, 1, height, arrowsize, exline, "h4=" + Math.Round(h4, 1), "", "");
                    fun.dimrot1(dxf, v80, v67, -90, b2 * 0.4, 1, height, arrowsize, exline, "h3=" + Math.Round(h3, 1), "", "");
                }

                if (ctrap == 7 || ctrap == 11)
                {
                    fun.dimrot1(dxf, v71, v68, 90, b2 / 2, 1, height, arrowsize, exline, "h7=" + Math.Round(h7, 1), "", "");
                    fun.dimrot1(dxf, v76, v68, 90, b2 / 6, 1, height, 0.5, exline, "2", "", "");
                    fun.dimrot1(dxf, v78, v68, 90, b2 * 0.4, 1, height, arrowsize, exline, "h6=" + Math.Round(h6, 1), "", "");
                    fun.dimrot1(dxf, v69, v67, -90, b2 * 0.4, 1, height, arrowsize, exline, "h3=" + Math.Round(h3, 1), "", "");
                    fun.dimrot1(dxf, v80, v67, -90, b2 * 0.4, 1, height, arrowsize, exline, "h4=" + Math.Round(h4, 1), "", "");
                }

                //角度标注
                if (ctrap == 4 || ctrap == 8)
                {
                    fun.jdbz1(dxf, new Line(v70, new Vector2(v70.X - 0.1, v70.Y)), new Line(v69, fun.Polar(v69, -165 * pi / 180, 0.1)), 25, "15°", height);
                    fun.jdbz1(dxf, new Line(v79, new Vector2(v79.X - 0.1, v79.Y)), new Line(v80, fun.Polar(v80, 165 * pi / 180, 0.1)), 20, "15°", height);
                }

                if (ctrap == 5 || ctrap == 9)
                {
                    fun.jdbz1(dxf, new Line(v70, new Vector2(v70.X + 0.1, v70.Y)), new Line(v69, fun.Polar(v69, -15 * pi / 180, 0.1)), 25, "15°", height);
                    fun.jdbz1(dxf, new Line(v79, new Vector2(v79.X + 0.1, v79.Y)), new Line(v80, fun.Polar(v80, 15 * pi / 180, 0.1)), 20, "15°", height);
                }

                if (ctrap == 6 || ctrap == 10)
                {
                    fun.jdbz1(dxf, new Line(v70, new Vector2(v70.X - 0.1, v70.Y)), new Line(v69, fun.Polar(v69, 165 * pi / 180, 0.1)), 20, "15°", height);
                    fun.jdbz1(dxf, new Line(v79, new Vector2(v79.X - 0.1, v79.Y)), new Line(v80, fun.Polar(v80, -165 * pi / 180, 0.1)), 20, "15°", height);
                }

                if (ctrap == 7 || ctrap == 11)
                {
                    fun.jdbz1(dxf, new Line(v70, new Vector2(v70.X + 0.1, v70.Y)), new Line(v69, fun.Polar(v69, 15 * pi / 180, 0.1)), 20, "15°", height);
                    fun.jdbz1(dxf, new Line(v79, new Vector2(v79.X + 0.1, v79.Y)), new Line(v80, fun.Polar(v80, -15 * pi / 180, 0.1)), 20, "15°", height);
                }
            }

            //19448.4 C型-----------------------------------------------------------------------------------------------
            //点------------------------------------------------------------------------------
            //第一部分
            Vector2 n7 = new Vector2(v48.X, v48.Y - fun.CalDistance(v48, v47) / 2);
            Vector2 n8 = new Vector2(n7.X + l1, n7.Y);

            if (ctrap == 12 || ctrap == 13 || ctrap == 14 || ctrap == 15)
            {
                n5 = new Vector2(v14.X, v14.Y - (v14.Y - v12.Y) * 0.6);
                n6 = new Vector2(n5.X + (l1 - l2), n5.Y);
                n1 = new Vector2(n5.X, n5.Y - h5 / 15);
                n2 = new Vector2(v15.X - 2, n1.Y);
                n3 = new Vector2(n2.X, v12.Y + h5 / 15);
                n4 = new Vector2(n1.X, n3.Y);
                if (ctrap == 14 || ctrap == 15)
                {
                    n1 = fun.mirrorpoint(n1, v12, v13);
                    n2 = fun.mirrorpoint(n2, v12, v13);
                    n3 = fun.mirrorpoint(n3, v12, v13);
                    n4 = fun.mirrorpoint(n4, v12, v13);
                }
            }

            //第二部分
            Vector2 v89 = new Vector2(v73.X + (h2 - h1) / 4, v84.Y);
            Vector2 v90 = new Vector2(v89.X, v83.Y);

            //第三部分
            //中心线点
            Vector2 v100 = new Vector2(v47.X - 10, v47.Y - l1 * 1.5);
            Vector2 v101 = new Vector2(v100.X + l1 * 2, v100.Y);

            //轮廓点
            Vector2 v102 = new Vector2(v47.X, v100.Y + 8);
            Vector2 v103 = new Vector2(v102.X + (l1 - l3), v102.Y);
            Vector2 v104 = new Vector2(v103.X, v103.Y + fun.CalDistance(v69f, v70));
            Vector2 v105 = new Vector2(v104.X + l3, v104.Y);
            Vector2 v106 = new Vector2(v105.X, v101.Y + fun.CalDistance(v38, v39) / 2);
            Vector2 v108 = new Vector2(v106.X + (v38.X - v18.X), v106.Y);
            Vector2 v109 = fun.mirrorpoint(v108, v100, v101);
            Vector2 v112 = fun.mirrorpoint(v106, v100, v101);
            Vector2 v113 = new Vector2(v105.X, v100.Y - fun.CalDistance(v70, v71));
            Vector2 v114 = new Vector2(v102.X, v113.Y);
            Vector2 v115 = new Vector2(v108.X, v108.Y - 2);
            Vector2 v116 = new Vector2(v106.X + 2, v115.Y);
            Vector2 v117 = fun.mirrorpoint(v116, v100, v101);
            Vector2 v118 = fun.mirrorpoint(v115, v100, v101);

            //C2型第二部分点
            Vector2 v67_1 = new Vector2(v13.X + l1 * 2, v13.Y);
            Vector2 v68_1 = new Vector2(v67_1.X + b4 * 1.5, v67_1.Y);
            Vector2 v85_1 = new Vector2(v67_1.X + 5 + (b4 - b5) * 1.5, v67_1.Y + h4 * 2);
            Vector2 v86_1 = fun.mirrorpoint(v85_1, v67_1, v68_1);
            Vector2 v69_1 = new Vector2(v67_1.X + 5, v67_1.Y + h4);
            Vector2 v69f_1 = new Vector2(v69_1.X, v15.Y);
            Vector2 v70_1 = new Vector2(v69_1.X + (v69f.Y - v69_1.Y) / Math.Tan(15 * pi / 180), v69f.Y);
            Vector2 v71_1 = new Vector2(v69_1.X + b4, v70_1.Y);
            Vector2 v72_1 = new Vector2(v71_1.X, v68.Y + (h2 - h1));
            Vector2 v73_1 = new Vector2(v72_1.X - (b5 - b6), v72_1.Y);
            Vector2 v74_1 = new Vector2(v73_1.X, v68_1.Y - 2);
            Vector2 v75_1 = new Vector2(v73_1.X, v68_1.Y - h1);
            Vector2 v76_1 = new Vector2(v72_1.X, v75_1.Y);
            Vector2 v78_1 = new Vector2(v76_1.X, v46_1.Y);
            Vector2 v80_1 = new Vector2(v69_1.X, v67_1.Y - h3);
            Vector2 v79_1 = fun.Inters(v80_1, fun.Polar(v80_1, -15 * pi / 180, l1), v78_1, new Vector2(v78_1.X - l1, v78_1.Y));
            Vector2 v81_1 = fun.Inters(v70_1, new Vector2(v70_1.X, v70_1.Y - l1), v74_1, new Vector2(v74_1.X - l1, v74_1.Y));
            Vector2 v82_1 = fun.Inters(v70_1, new Vector2(v70_1.X, v70_1.Y - l1 * 2), v80_1, fun.Polar(v80_1, -15 * pi / 180, l1));
            Vector2 v83_1 = new Vector2(v72_1.X, v73_1.Y - (h2 - h1) / 6);
            Vector2 v84_1 = new Vector2(v83_1.X, v83_1.Y - (h2 - h1) / 1.5);
            Vector2 v89_1 = new Vector2(v73_1.X + (h2 - h1) / 6, v84_1.Y);
            Vector2 v90_1 = new Vector2(v89_1.X, v83_1.Y);

            //C4型第一部分新增点
            Vector2 c3_1 = new Vector2(v14.X, v14.Y - h6 / 8);
            Vector2 c3_2 = new Vector2(c3_1.X + fun.CalDistance(v14, v15) / 2, c3_1.Y);
            Vector2 c3_4 = new Vector2(v47.X, v47.Y + h6 / 8);
            Vector2 c3_3 = new Vector2(c3_2.X, c3_4.Y);
            Vector2 c3_5_1 = new Vector2(c3_3.X, c3_3.Y + h6 / 8);
            Vector2 c3_6_1 = new Vector2(c3_2.X, c3_2.Y - h6 / 8);
            Vector2 c3_5 = fun.Inters(c3_5_1, new Vector2(c3_5_1.X + l1, c3_5_1.Y), v46_1, v46);
            if (v46.Y < c3_5_1.Y)
            {
                c3_5 = fun.Inters(c3_5_1, new Vector2(c3_5_1.X + l1, c3_5_1.Y), v15, v46);
            }
            Vector2 c3_6 = fun.Inters(c3_6_1, new Vector2(c3_6_1.X + l1, c3_6_1.Y), v15, v46);

            //作图部分------------------------------------------------------------------------
            if (ctrap == 12 || ctrap == 13 || ctrap == 14 || ctrap == 15)//C1,C2,C3
            {
                //中心线
                //第一部分
                Line centre_line3 = new Line(v12, v13);
                centre_line3.Layer = centre;
                centre_line3.Linetype = Linetype.Center;
                centre_line3.LinetypeScale = 5;
                dxf.AddEntity(centre_line3);

                if (ctrap == 12 || ctrap == 14)
                {
                    //第二部分
                    Line centre_line4 = new Line(v67, v68);
                    centre_line4.Layer = centre;
                    centre_line4.Linetype = Linetype.Center;
                    centre_line4.LinetypeScale = 5;
                    dxf.AddEntity(centre_line4);
                    Line centre_line5 = new Line(v85, v86);
                    centre_line5.Layer = centre;
                    centre_line5.Linetype = Linetype.Center;
                    centre_line5.LinetypeScale = 5;
                    dxf.AddEntity(centre_line5);
                }

                if (ctrap == 13 || ctrap == 15)
                {
                    //第二部分
                    Line centre_line4 = new Line(v67_1, v68_1);
                    centre_line4.Layer = centre;
                    centre_line4.Linetype = Linetype.Center;
                    centre_line4.LinetypeScale = 5;
                    dxf.AddEntity(centre_line4);
                    Line centre_line5 = new Line(v85_1, v86_1);
                    centre_line5.Layer = centre;
                    centre_line5.Linetype = Linetype.Center;
                    centre_line5.LinetypeScale = 5;
                    dxf.AddEntity(centre_line5);
                }

                //第三部分
                Line centre_line6 = new Line(v100, v101);
                centre_line6.Layer = centre;
                centre_line6.Linetype = Linetype.Center;
                centre_line6.LinetypeScale = 5;
                dxf.AddEntity(centre_line6);

                //作图
                //第一部分
                if (ctrap != 15)
                {
                    if (ctrap == 14)
                    {
                        n5 = fun.mirrorpoint(n5, v12, v13);
                        n6 = fun.mirrorpoint(n6, v12, v13);
                    }
                    Vector2[] Line1 = { n5, n6 };
                    fun.drawBLine(dxf, Line1, 0.3, contour);
                }

                if (ctrap != 15)
                {
                    if (ctrap == 14)
                    {
                        n7 = fun.mirrorpoint(n7, v12, v13);
                        n8 = fun.mirrorpoint(n8, v12, v13);
                    }
                    Vector2[] Line2 = { n7, n8 };
                    fun.drawBLine(dxf, Line2, 0.3, contour);
                }

                if (ctrap == 15)
                {
                    LwPolyline polylineC_1 = new LwPolyline();
                    polylineC_1.Vertexes.Add(new LwPolylineVertex(c3_1));
                    polylineC_1.Vertexes.Add(new LwPolylineVertex(c3_2));
                    polylineC_1.Vertexes.Add(new LwPolylineVertex(c3_3));
                    polylineC_1.Vertexes.Add(new LwPolylineVertex(c3_4));
                    polylineC_1 = Pus.MirrorPolyline(polylineC_1, v12, v13);
                    fun.PolyFill(dxf, polylineC_1, 0.3, contour);

                    LwPolyline polylineC_2 = new LwPolyline();
                    polylineC_2.Vertexes.Add(new LwPolylineVertex(c3_5_1));
                    polylineC_2.Vertexes.Add(new LwPolylineVertex(c3_5));
                    polylineC_2 = Pus.MirrorPolyline(polylineC_2, v12, v13);
                    fun.PolyFill(dxf, polylineC_2, 0.3, contour);

                    LwPolyline polylineC_3 = new LwPolyline();
                    polylineC_3.Vertexes.Add(new LwPolylineVertex(c3_6_1));
                    polylineC_3.Vertexes.Add(new LwPolylineVertex(c3_6));
                    polylineC_3 = Pus.MirrorPolyline(polylineC_3, v12, v13);
                    fun.PolyFill(dxf, polylineC_3, 0.3, contour);
                }

                LwPolyline polyline1 = new LwPolyline();
                polyline1.Vertexes.Add(new LwPolylineVertex(v14));
                polyline1.Vertexes.Add(new LwPolylineVertex(v15));
                polyline1.Vertexes.Add(new LwPolylineVertex(v46));
                polyline1.Vertexes.Add(new LwPolylineVertex(v46_1));
                polyline1.Vertexes.Add(new LwPolylineVertex(v47));
                polyline1.Vertexes.Add(new LwPolylineVertex(v48));
                polyline1.Vertexes.Add(new LwPolylineVertex(v49));
                polyline1.Vertexes.Add(new LwPolylineVertex(v14));
                if (ctrap == 14 || ctrap == 15)
                {
                    polyline1 = Pus.MirrorPolyline(polyline1, v12, v13);
                    v14 = polyline1.Vertexes[0].Position;
                    v15 = polyline1.Vertexes[1].Position;
                    v46 = polyline1.Vertexes[2].Position;
                    v46_1 = polyline1.Vertexes[3].Position;
                    v47 = polyline1.Vertexes[4].Position;
                    v48 = polyline1.Vertexes[5].Position;
                    v49 = polyline1.Vertexes[6].Position;
                }
                fun.PolyFill(dxf, polyline1, 0.3, contour);

                LwPolyline polyline2 = new LwPolyline();
                polyline2.Vertexes.Add(new LwPolylineVertex(v18));
                polyline2.Vertexes.Add(new LwPolylineVertex(v19));
                polyline2.Vertexes.Add(new LwPolylineVertex(v20));
                polyline2.Vertexes.Add(new LwPolylineVertex(v21));
                polyline2.Vertexes.Add(new LwPolylineVertex(v22));
                polyline2.Vertexes.Add(new LwPolylineVertex(v23));
                polyline2.Vertexes.Add(new LwPolylineVertex(v24));
                polyline2.Vertexes.Add(new LwPolylineVertex(v25));
                polyline2.Vertexes.Add(new LwPolylineVertex(v26));
                polyline2.Vertexes.Add(new LwPolylineVertex(v27));
                polyline2.Vertexes.Add(new LwPolylineVertex(v28));
                polyline2.Vertexes.Add(new LwPolylineVertex(v29));
                polyline2.Vertexes.Add(new LwPolylineVertex(v30_1));
                polyline2.Vertexes.Add(new LwPolylineVertex(v30));
                polyline2.Vertexes.Add(new LwPolylineVertex(v31));
                polyline2.Vertexes.Add(new LwPolylineVertex(v32));
                polyline2.Vertexes.Add(new LwPolylineVertex(v33));
                polyline2.Vertexes.Add(new LwPolylineVertex(v34));
                polyline2.Vertexes.Add(new LwPolylineVertex(v35));
                polyline2.Vertexes.Add(new LwPolylineVertex(v36));
                polyline2.Vertexes.Add(new LwPolylineVertex(v37));
                polyline2.Vertexes.Add(new LwPolylineVertex(v38));
                polyline2.Vertexes.Add(new LwPolylineVertex(v39));
                polyline2.Vertexes.Add(new LwPolylineVertex(v41));
                fun.PolyFill(dxf, polyline2, 0.3, contour);

                if (ctrap != 15)
                {
                    LwPolyline polyline3 = new LwPolyline();
                    polyline3.Vertexes.Add(new LwPolylineVertex(n1));
                    polyline3.Vertexes.Add(new LwPolylineVertex(n2));
                    polyline3.Vertexes.Add(new LwPolylineVertex(n3));
                    polyline3.Vertexes.Add(new LwPolylineVertex(n4));
                    fun.PolyFill(dxf, polyline3, 0.3, contour);
                }

                if (ctrap == 12 || ctrap == 14)
                {
                    //第二部分
                    //虚线
                    Circle circle1 = new Circle(v87, fun.CalDistance(v38, v39) / 2);
                    circle1.Layer = refin;
                    circle1.Linetype = Linetype.Dashed;
                    circle1.LinetypeScale = 5;
                    dxf.AddEntity(circle1);

                    Circle circle2 = new Circle(v88, fun.CalDistance(v38, v39) / 4);
                    circle2.Layer = refin;
                    circle2.Linetype = Linetype.Dashed;
                    circle2.LinetypeScale = 5;
                    dxf.AddEntity(circle2);

                    Line line1 = new Line(v87, v88);
                    line1.Layer = refin;
                    line1.Linetype = Linetype.Dashed;
                    line1.LinetypeScale = 5;
                    dxf.AddEntity(line1);

                    //轮廓
                    Vector2[] Line3 = { v70, v82 };
                    fun.drawBLine(dxf, Line3, 0.3, contour);

                    v74 = new Vector2(v73.X, v68.Y - 2);
                    v81 = fun.Inters(v74, new Vector2(v74.X - l1, v74.Y), v70, v82);
                    Vector2[] Line4 = { v74, v81 };
                    fun.drawBLine(dxf, Line4, 0.3, contour);

                    LwPolyline polyline4 = new LwPolyline();
                    polyline4.Vertexes.Add(new LwPolylineVertex(v69));
                    polyline4.Vertexes.Add(new LwPolylineVertex(v70));
                    polyline4.Vertexes.Add(new LwPolylineVertex(v71));
                    polyline4.Vertexes.Add(new LwPolylineVertex(v72));
                    polyline4.Vertexes.Add(new LwPolylineVertex(v73));
                    polyline4.Vertexes.Add(new LwPolylineVertex(v75));
                    polyline4.Vertexes.Add(new LwPolylineVertex(v76));
                    polyline4.Vertexes.Add(new LwPolylineVertex(v78));
                    polyline4.Vertexes.Add(new LwPolylineVertex(v79));
                    polyline4.Vertexes.Add(new LwPolylineVertex(v80));
                    polyline4.Vertexes.Add(new LwPolylineVertex(v69));
                    if (ctrap == 14)
                    {
                        polyline4 = Pus.MirrorPolyline(polyline4, v67, v68);
                        v69 = polyline4.Vertexes[0].Position;
                        v70 = polyline4.Vertexes[1].Position;
                        v71 = polyline4.Vertexes[2].Position;
                        v72 = polyline4.Vertexes[3].Position;
                        v73 = polyline4.Vertexes[4].Position;
                        v75 = polyline4.Vertexes[5].Position;
                        v76 = polyline4.Vertexes[6].Position;
                        v78 = polyline4.Vertexes[7].Position;
                        v79 = polyline4.Vertexes[8].Position;
                        v80 = polyline4.Vertexes[9].Position;
                    }
                    fun.PolyFill(dxf, polyline4, 0.3, contour);

                    LwPolyline polyline5 = new LwPolyline();
                    polyline5.Vertexes.Add(new LwPolylineVertex(v83));
                    polyline5.Vertexes.Add(new LwPolylineVertex(v84));
                    polyline5.Vertexes.Add(new LwPolylineVertex(v89));
                    polyline5.Vertexes.Add(new LwPolylineVertex(v90));
                    polyline5.Vertexes.Add(new LwPolylineVertex(v83));
                    if (ctrap == 14)
                    {
                        polyline5 = Pus.MirrorPolyline(polyline5, v67, v68);
                    }
                    fun.PolyFill(dxf, polyline5, 0.3, contour);
                }

                if (ctrap == 13 || ctrap == 15)
                {
                    //第二部分
                    //虚线
                    /*Circle circle1 = new Circle(v87, fun.CalDistance(v38, v39) / 2);
                    circle1.Layer = refin;
                    circle1.Linetype = Linetype.Dashed;
                    circle1.LinetypeScale = 5;
                    dxf.AddEntity(circle1);

                    Circle circle2 = new Circle(v88, fun.CalDistance(v38, v39) / 4);
                    circle2.Layer = refin;
                    circle2.Linetype = Linetype.Dashed;
                    circle2.LinetypeScale = 5;
                    dxf.AddEntity(circle2);

                    Line line1 = new Line(v87, v88);
                    line1.Layer = refin;
                    line1.Linetype = Linetype.Dashed;
                    line1.LinetypeScale = 5;
                    dxf.AddEntity(line1);*/

                    //轮廓
                    LwPolyline polyline4 = new LwPolyline();
                    polyline4.Vertexes.Add(new LwPolylineVertex(v69_1));
                    polyline4.Vertexes.Add(new LwPolylineVertex(v70_1));
                    polyline4.Vertexes.Add(new LwPolylineVertex(v71_1));
                    polyline4.Vertexes.Add(new LwPolylineVertex(v72_1));
                    polyline4.Vertexes.Add(new LwPolylineVertex(v73_1));
                    polyline4.Vertexes.Add(new LwPolylineVertex(v75_1));
                    polyline4.Vertexes.Add(new LwPolylineVertex(v76_1));
                    polyline4.Vertexes.Add(new LwPolylineVertex(v78_1));
                    polyline4.Vertexes.Add(new LwPolylineVertex(v79_1));
                    polyline4.Vertexes.Add(new LwPolylineVertex(v80_1));
                    polyline4.Vertexes.Add(new LwPolylineVertex(v69_1));
                    polyline4 = Pus.MirrorPolyline(polyline4, v85_1, v86_1);
                    if (ctrap == 15)
                    {
                        polyline4 = Pus.MirrorPolyline(polyline4, v67_1, v68_1);
                    }
                    v69_1 = polyline4.Vertexes[0].Position;
                    v70_1 = polyline4.Vertexes[1].Position;
                    v71_1 = polyline4.Vertexes[2].Position;
                    v72_1 = polyline4.Vertexes[3].Position;
                    v73_1 = polyline4.Vertexes[4].Position;
                    v75_1 = polyline4.Vertexes[5].Position;
                    v76_1 = polyline4.Vertexes[6].Position;
                    v78_1 = polyline4.Vertexes[7].Position;
                    v79_1 = polyline4.Vertexes[8].Position;
                    v80_1 = polyline4.Vertexes[9].Position;
                    fun.PolyFill(dxf, polyline4, 0.3, contour);

                    LwPolyline polyline5 = new LwPolyline();
                    polyline5.Vertexes.Add(new LwPolylineVertex(v83_1));
                    polyline5.Vertexes.Add(new LwPolylineVertex(v84_1));
                    polyline5.Vertexes.Add(new LwPolylineVertex(v89_1));
                    polyline5.Vertexes.Add(new LwPolylineVertex(v90_1));
                    polyline5.Vertexes.Add(new LwPolylineVertex(v83_1));
                    polyline5 = Pus.MirrorPolyline(polyline5, v85_1, v86_1);
                    if (ctrap == 15)
                    {
                        polyline5 = Pus.MirrorPolyline(polyline5, v67_1, v68_1);
                    }
                    fun.PolyFill(dxf, polyline5, 0.3, contour);

                    v82_1 = fun.mirrorpoint(v82_1, v85_1, v86_1);
                    if (ctrap == 15)
                    {
                        v82_1 = fun.mirrorpoint(v82_1, v67_1, v68_1);
                    }
                    Vector2[] Line3 = { v70_1, v82_1 };
                    fun.drawBLine(dxf, Line3, 0.3, contour);

                    v74_1 = fun.mirrorpoint(v74_1, v85_1, v86_1);
                    v81_1 = fun.mirrorpoint(v81_1, v85_1, v86_1);
                    if (ctrap == 15)
                    {
                        v74_1 = fun.mirrorpoint(v74_1, v67_1, v68_1);
                        v81_1 = fun.mirrorpoint(v81_1, v67_1, v68_1);
                    }
                    Vector2[] Line4 = { v74_1, v81_1 };
                    fun.drawBLine(dxf, Line4, 0.3, contour);
                }

                //第三部分
                Vector2[] Line5 = { v106, v112 };
                fun.drawBLine(dxf, Line5, 0.3, contour);

                LwPolyline polyline6 = new LwPolyline();
                polyline6.Vertexes.Add(new LwPolylineVertex(v102));
                polyline6.Vertexes.Add(new LwPolylineVertex(v103));
                polyline6.Vertexes.Add(new LwPolylineVertex(v104));
                polyline6.Vertexes.Add(new LwPolylineVertex(v105));
                polyline6.Vertexes.Add(new LwPolylineVertex(v106));
                polyline6.Vertexes.Add(new LwPolylineVertex(v108));
                polyline6.Vertexes.Add(new LwPolylineVertex(v109));
                polyline6.Vertexes.Add(new LwPolylineVertex(v112));
                polyline6.Vertexes.Add(new LwPolylineVertex(v113));
                polyline6.Vertexes.Add(new LwPolylineVertex(v114));
                polyline6.Vertexes.Add(new LwPolylineVertex(v102));
                if (ctrap == 13 || ctrap == 15)
                {
                    polyline6 = Pus.MirrorPolyline(polyline6, v100, v101);
                    v104 = polyline6.Vertexes[2].Position;
                    v105 = polyline6.Vertexes[3].Position;
                }
                fun.PolyFill(dxf, polyline6, 0.3, contour);

                LwPolyline polyline7 = new LwPolyline();
                polyline7.Vertexes.Add(new LwPolylineVertex(v115));
                polyline7.Vertexes.Add(new LwPolylineVertex(v116));
                polyline7.Vertexes.Add(new LwPolylineVertex(v117));
                polyline7.Vertexes.Add(new LwPolylineVertex(v118));
                if (ctrap == 13 || ctrap == 15)
                {
                    polyline7 = Pus.MirrorPolyline(polyline7, v100, v101);
                }
                fun.PolyFill(dxf, polyline7, 0.3, contour);

                //标注-------------------------------------------------------------------------------------------
                //第一部分
                //直线标注
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 1;
                dimensionStyle.ExtLineExtend = 0.6;//标注延长线长度/2
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;

                //文本样式
                dimensionStyle.TextHeight = 1;

                double height = 2;
                double arrowsize = 1;
                double exline = 2;

                //第一部分
                //直线标注
                if (ctrap == 12 || ctrap == 13)
                {
                    fun.dimrot1(dxf, v48, v15, 0, h2 * 1.4, 1, height, arrowsize, exline, "l1=" + Math.Round(l1, 1), "", "");
                    fun.dimrot1(dxf, v48, v14, 0, h2, 1, height, arrowsize, exline, "l2=" + Math.Round(l2, 1), "", "");
                    fun.dimrot1(dxf, v14, v12, 90, l2 * 3, 1, height, arrowsize, exline, "h5=" + Math.Round(h5, 1), "", "");
                    fun.dimrot1(dxf, v12, v47, 90, l2 * 3, 1, height, arrowsize, exline, "h6=" + Math.Round(h6, 1), "", "");
                    fun.dimrot1(dxf, v46, v12, 90, 0, 1, height, arrowsize, exline, "h8=" + Math.Round(h8, 1), "", "");
                    fun.dimrot1(dxf, v48, v12, 90, l2, 1, height, arrowsize, exline, "2", "", "");

                    Line line3 = new Line(v39, new Vector2(v39.X + l7, v39.Y));
                    line3.Layer = dimensioning;
                    dxf.AddEntity(line3);
                    fun.jt1(dxf, new Vector2(v39.X + l7 - 1, v39.Y), 90, h2 / 2, 1, "φd1=" + Math.Round(d1, 1), 2);
                    fun.jt1(dxf, v21, 60, h2 / 2, 1, "a=" + Math.Round(b, 1), 2);

                    //角度标注
                    fun.jdbz1(dxf, new Line(v46_1, new Vector2(v46_1.X + 0.1, v46_1.Y)), new Line(v46, fun.Polar(v46, a * pi / 180, 0.1)), l1 / 2, "α=" + a, height);
                }

                if (ctrap == 14 || ctrap == 15)
                {
                    fun.dimrot1(dxf, v46, v47, 0, h2 * 1.4, 1, height, arrowsize, exline, "l1=" + Math.Round(l1, 1), "", "");
                    fun.dimrot1(dxf, v48, v14, 180, h2, 1, height, arrowsize, exline, "l2=" + Math.Round(l2, 1), "", "");
                    fun.dimrot1(dxf, v14, v12, 90, l2 * 3, 1, height, arrowsize, exline, "h7=" + Math.Round(h7, 1), "", "");
                    fun.dimrot1(dxf, v12, v47, 90, l2 * 3, 1, height, arrowsize, exline, "h6=" + Math.Round(h6, 1), "", "");
                    fun.dimrot1(dxf, v46, v12, 90, 0, 1, height, arrowsize, exline, "h9=" + Math.Round(h9, 1), "", "");
                    fun.dimrot1(dxf, v48, v12, 90, l2, 1, height, arrowsize, exline, "2", "", "");

                    Line line3 = new Line(v39, new Vector2(v39.X + l7, v39.Y));
                    line3.Layer = dimensioning;
                    dxf.AddEntity(line3);
                    fun.jt1(dxf, new Vector2(v39.X + l7 - 1, v39.Y), 90, h2 / 2, 1, "φd1=" + Math.Round(d1, 1), 2);
                    fun.jt1(dxf, v21, 30, h2 / 2, 1, "a=" + Math.Round(b, 1), 2);

                    //角度标注
                    fun.jdbz1(dxf, new Line(v46_1, new Vector2(v46_1.X + 0.1, v46_1.Y)), new Line(v46, fun.Polar(v46, -a * pi / 180, 0.1)), l1 / 2, "α=" + a, height);
                }

                if (ctrap == 12)
                {
                    //第二部分
                    //直线标注
                    fun.dimrot1(dxf, v69, v71, 0, h2 * 1.4, 1, height, arrowsize, exline, "b1=" + Math.Round(b1, 1), "", "");
                    fun.dimrot1(dxf, v85, v71, 0, h2 / 2, 1, height, arrowsize, exline, "b2=" + Math.Round(b2, 1), "", "");
                    fun.dimrot1(dxf, v69, v67, 90, b2 / 2, 1, height, arrowsize, exline, "h4=" + Math.Round(h4, 1), "", "");
                    fun.dimrot1(dxf, v80, v67, 90, b2 / 2, 1, height, arrowsize, exline, "h3=" + Math.Round(h3, 1), "", "");
                    fun.dimrot1(dxf, v86, v75, 180, h2, 1, height, arrowsize, exline, "b3=" + Math.Round(b3, 1), "", "");
                    fun.dimrot1(dxf, v72, v76, -90, b2, 1, height, arrowsize, exline, "h2=" + Math.Round(h2, 1), "", "");
                    fun.dimrot1(dxf, v68, v76, -90, b2 / 3, 1, height, arrowsize, exline, "h1=" + Math.Round(h1, 1), "", "");

                    //角度标注
                    fun.jdbz1(dxf, new Line(v70, new Vector2(v70.X - 0.1, v70.Y)), new Line(v69, fun.Polar(v69, -165 * pi / 180, 0.1)), 25, "15°", height);
                    fun.jdbz1(dxf, new Line(v79, new Vector2(v79.X - 0.1, v79.Y)), new Line(v80, fun.Polar(v80, 165 * pi / 180, 0.1)), 25, "15°", height);
                }

                if (ctrap == 13)
                {
                    //第二部分
                    //直线标注
                    v67_1 = fun.mirrorpoint(v67_1, v85_1, v86_1);
                    v68_1 = fun.mirrorpoint(v68_1, v85_1, v86_1);
                    fun.dimrot1(dxf, v69_1, v71_1, 0, h2 * 1.4, 1, height, arrowsize, exline, "b4=" + Math.Round(b4, 1), "", "");
                    fun.dimrot1(dxf, v85_1, v71_1, 0, h2 / 2, 1, height, arrowsize, exline, "b5=" + Math.Round(b5, 1), "", "");
                    fun.dimrot1(dxf, v69_1, v67_1, -90, b2 / 2, 1, height, arrowsize, exline, "h4=" + Math.Round(h4, 1), "", "");
                    fun.dimrot1(dxf, v80_1, v67_1, -90, b2 / 2, 1, height, arrowsize, exline, "h3=" + Math.Round(h3, 1), "", "");
                    fun.dimrot1(dxf, v86_1, v75_1, 180, h2, 1, height, arrowsize, exline, "b6=" + Math.Round(b6, 1), "", "");
                    fun.dimrot1(dxf, v72_1, v76_1, 90, b2, 1, height, arrowsize, exline, "h2=" + Math.Round(h2, 1), "", "");
                    fun.dimrot1(dxf, v68_1, v76_1, 90, b2 / 3, 1, height, arrowsize, exline, "h1=" + Math.Round(h1, 1), "", "");

                    //角度标注
                    fun.jdbz1(dxf, new Line(v70_1, new Vector2(v70_1.X + 0.1, v70_1.Y)), new Line(v69_1, fun.Polar(v69_1, -15 * pi / 180, 0.1)), 25, "15°", height);
                    fun.jdbz1(dxf, new Line(v79_1, new Vector2(v79_1.X + 0.1, v79_1.Y)), new Line(v80_1, fun.Polar(v80_1, 15 * pi / 180, 0.1)), 25, "15°", height);
                }

                if (ctrap == 15)
                {
                    //第二部分
                    //直线标注
                    v67_1 = fun.mirrorpoint(v67_1, v85_1, v86_1);
                    v68_1 = fun.mirrorpoint(v68_1, v85_1, v86_1);
                    fun.dimrot1(dxf, v69_1, v71_1, 180, h2 * 1.4, 1, height, arrowsize, exline, "b4=" + Math.Round(b4, 1), "", "");
                    fun.dimrot1(dxf, v85_1, v78_1, 0, h2 / 2, 1, height, arrowsize, exline, "b5=" + Math.Round(b5, 1), "", "");
                    fun.dimrot1(dxf, v69_1, v67_1, -90, b2 / 2, 1, height, arrowsize, exline, "h4=" + Math.Round(h4, 1), "", "");
                    fun.dimrot1(dxf, v80_1, v67_1, -90, b2 / 2, 1, height, arrowsize, exline, "h3=" + Math.Round(h3, 1), "", "");
                    fun.dimrot1(dxf, v86_1, v75_1, 180, h2, 1, height, arrowsize, exline, "b6=" + Math.Round(b6, 1), "", "");
                    fun.dimrot1(dxf, v72_1, v76_1, 90, b2, 1, height, arrowsize, exline, "h2=" + Math.Round(h2, 1), "", "");
                    fun.dimrot1(dxf, v68_1, v76_1, 90, b2 / 3, 1, height, arrowsize, exline, "h1=" + Math.Round(h1, 1), "", "");

                    //角度标注
                    fun.jdbz1(dxf, new Line(v70_1, new Vector2(v70_1.X + 0.1, v70_1.Y)), new Line(v69_1, fun.Polar(v69_1, 15 * pi / 180, 0.1)), 25, "15°", height);
                    fun.jdbz1(dxf, new Line(v79_1, new Vector2(v79_1.X + 0.1, v79_1.Y)), new Line(v80_1, fun.Polar(v80_1, -15 * pi / 180, 0.1)), 25, "15°", height);
                }

                if (ctrap == 14)
                {
                    //第二部分
                    //直线标注
                    fun.dimrot1(dxf, v80, v78, 0, h2 * 1.4, 1, height, arrowsize, exline, "b1=" + Math.Round(b1, 1), "", "");
                    fun.dimrot1(dxf, v85, v78, 0, h2 / 2, 1, height, arrowsize, exline, "b2=" + Math.Round(b2, 1), "", "");
                    fun.dimrot1(dxf, v69, v67, 90, b2 / 2, 1, height, arrowsize, exline, "h4=" + Math.Round(h4, 1), "", "");
                    fun.dimrot1(dxf, v80, v67, 90, b2 / 2, 1, height, arrowsize, exline, "h3=" + Math.Round(h3, 1), "", "");
                    fun.dimrot1(dxf, v86, v73, 180, h2, 1, height, arrowsize, exline, "b3=" + Math.Round(b3, 1), "", "");
                    fun.dimrot1(dxf, v72, v76, -90, b2, 1, height, arrowsize, exline, "h2=" + Math.Round(h2, 1), "", "");
                    fun.dimrot1(dxf, v68, v76, -90, b2 / 3, 1, height, arrowsize, exline, "h1=" + Math.Round(h1, 1), "", "");

                    //角度标注
                    fun.jdbz1(dxf, new Line(v70, new Vector2(v70.X - 0.1, v70.Y)), new Line(v69, fun.Polar(v69, 165 * pi / 180, 0.1)), 25, "15°", height);
                    fun.jdbz1(dxf, new Line(v79, new Vector2(v79.X - 0.1, v79.Y)), new Line(v80, fun.Polar(v80, -165 * pi / 180, 0.1)), 25, "15°", height);
                }

                //第三部分
                //直线标注
                if (ctrap == 12)
                {
                    fun.dimrot1(dxf, v102, v100, 90, l3, 1, height, arrowsize, exline, "8", "", "");
                    fun.dimrot1(dxf, v104, v105, 0, h6 / 2, 1, height, arrowsize, exline, "l3=" + Math.Round(l3, 1), "", "");
                }
                if (ctrap == 13 || ctrap == 15)
                {
                    fun.dimrot1(dxf, v102, v100, 90, l3, 1, height, arrowsize, exline, "8", "", "");
                    fun.dimrot1(dxf, v104, v105, 180, h6 / 2, 1, height, arrowsize, exline, "l3=" + Math.Round(l3, 1), "", "");
                }
                if (ctrap == 14)
                {
                    fun.dimrot1(dxf, v102, v100, 90, l3, 1, height, arrowsize, exline, "8", "", "");
                    fun.dimrot1(dxf, v104, v105, 0, h6 / 2, 1, height, arrowsize, exline, "l3=" + Math.Round(l3, 1), "", "");
                }

            }

            //D型----------------------------------------------------------------------------------------------------------------
            //D型共用点
            Vector2 D1 = new Vector2(0, 0);
            Vector2 D2 = new Vector2(D1.X + l2 * 2.2, D1.Y);
            Vector2 D3 = new Vector2(D1.X + 5, D1.Y + h3);
            Vector2 D4 = new Vector2(D3.X + l2, D3.Y);
            Vector2 D5 = new Vector2(D4.X, D1.Y - h6);
            Vector2 D6 = fun.Polar(D5, -150 * pi / 180, (h4 - h6) / Math.Sin(a * pi / 180));
            Vector2 D7 = new Vector2(D3.X, D1.Y - h4);
            Vector2 D8 = new Vector2(D7.X, D1.Y - h1);
            Vector2 D9 = new Vector2(D8.X + (l2 - l1), D8.Y);
            Vector2 D10 = new Vector2(D9.X, D9.Y + h2);
            Vector2 D11 = new Vector2(D3.X, D8.Y + h2);
            double D = (h2 - h1) / 6;
            Vector2 D12 = new Vector2(D11.X, D11.Y - D);
            Vector2 D13 = new Vector2(D12.X, D1.Y + D);
            Vector2 D14 = new Vector2(D10.X - D, D12.Y);
            Vector2 D15 = new Vector2(D10.X - D, D13.Y);
            Vector2 D16 = new Vector2(D10.X + D, D12.Y);
            Vector2 D17 = new Vector2(D10.X + D, D13.Y);
            Vector2 D18 = new Vector2(D4.X, D16.Y);
            Vector2 D19 = new Vector2(D4.X, D17.Y);
            Vector2 D20 = fun.Inters(D10, new Vector2(D10.X + l1, D10.Y), D4, D5);
            Vector2 D21 = fun.Inters(D9, new Vector2(D9.X + l1, D9.Y), D4, D5);
            Vector2 D22 = new Vector2(D2.X + l1, D2.Y);
            Vector2 D23 = new Vector2(D22.X + l1 * 2.2, D22.Y);
            Vector2 D22_1 = new Vector2(D22.X + fun.CalDistance(D22, D23) / 2, D22.Y + fun.CalDistance(D22, D23) / 2);
            Vector2 D23_1 = fun.mirrorpoint(D22_1, D22, D23);
            Vector2 D24 = new Vector2(D22.X + 5, D22.Y + h3);
            Vector2 D25 = new Vector2(D24.X + b3 + b1, D24.Y);
            Vector2 D26 = new Vector2(D25.X, D25.Y - h3 * 2 / 3);
            Vector2 D27 = new Vector2(D24.X, D26.Y);
            Vector2 D28 = new Vector2(D27.X, D27.Y - h3 / 14);
            Vector2 D29 = new Vector2(D22_1.X - b4 - h3 / 14, D28.Y);
            Vector2 D30 = new Vector2(D29.X, D22.Y + h3 / 14);
            Vector2 D31 = new Vector2(D28.X, D30.Y);
            Vector2 D32 = new Vector2(D22_1.X - b4 + h3 / 14, D29.Y);
            Vector2 D33 = new Vector2(D32.X, D30.Y);
            Vector2 D34 = new Vector2(D22_1.X + b2 - h3 / 14, D32.Y);
            Vector2 D35 = new Vector2(D34.X, D33.Y);
            Vector2 D36 = new Vector2(D22_1.X + b2 + h3 / 14, D34.Y);
            Vector2 D37 = new Vector2(D26.X, D36.Y);
            Vector2 D38 = new Vector2(D36.X, D23.Y + h3 / 14);
            Vector2 D39 = new Vector2(D37.X, D38.Y);
            Vector2 D40 = new Vector2(D31.X, D22.Y - h4 / 2);
            Vector2 D41 = new Vector2(D31.X, D22.Y - h4);
            Vector2 D42 = new Vector2(D26.X, D41.Y);
            Vector2 D43 = new Vector2(D26.X, D40.Y);
            Vector2 D44 = new Vector2(D22_1.X - b4, D27.Y);
            Vector2 D45 = new Vector2(D22_1.X + b2, D27.Y);
            Vector2 D46 = new Vector2(D22_1.X - b4, D40.Y);
            Vector2 D47 = new Vector2(D22_1.X + b2, D40.Y);
            Vector2 D48 = fun.Inters(D22_1, D23_1, D23, D22);
            Vector2 D49 = fun.Polar(D48, -120 * pi / 180, fun.CalDistance(D44, D46));
            Vector2 D50 = new Vector2(D41.X, D41.Y + fun.CalDistance(D40, D41) * 1 / 3);
            Vector2 D51 = new Vector2(D42.X, D42.Y + fun.CalDistance(D40, D41) * 1 / 3);
            if (ctrap == 16 || ctrap == 17)
            {
                v39 = new Vector2(v38.X, D21.Y);
            }

            //D型作图
            //D1，D2型
            if (ctrap == 16 || ctrap == 17)
            {
                //第一部分
                //中心线
                Line line1 = new Line(D1, D2);
                line1.Layer = centre;
                line1.Linetype = Linetype.Center;
                line1.LinetypeScale = 5;
                dxf.AddEntity(line1);

                LwPolyline polyline1 = new LwPolyline();
                polyline1.Vertexes.Add(new LwPolylineVertex(D3));
                polyline1.Vertexes.Add(new LwPolylineVertex(D4));
                polyline1.Vertexes.Add(new LwPolylineVertex(D5));
                polyline1.Vertexes.Add(new LwPolylineVertex(D6));
                polyline1.Vertexes.Add(new LwPolylineVertex(D7));
                polyline1.Vertexes.Add(new LwPolylineVertex(D8));
                polyline1.Vertexes.Add(new LwPolylineVertex(D9));
                polyline1.Vertexes.Add(new LwPolylineVertex(D10));
                polyline1.Vertexes.Add(new LwPolylineVertex(D11));
                polyline1.Vertexes.Add(new LwPolylineVertex(D3));
                if (ctrap == 17)
                {
                    polyline1 = Pus.MirrorPolyline(polyline1, D1, D2);
                    D3 = polyline1.Vertexes[0].Position;
                    D4 = polyline1.Vertexes[1].Position;
                    D5 = polyline1.Vertexes[2].Position;
                    D6 = polyline1.Vertexes[3].Position;
                    D7 = polyline1.Vertexes[4].Position;
                    D8 = polyline1.Vertexes[5].Position;
                    D9 = polyline1.Vertexes[6].Position;
                    D10 = polyline1.Vertexes[7].Position;
                    D11 = polyline1.Vertexes[8].Position;
                }
                fun.PolyFill(dxf, polyline1, 0.3, contour);

                LwPolyline polyline2 = new LwPolyline();
                polyline2.Vertexes.Add(new LwPolylineVertex(v18));
                polyline2.Vertexes.Add(new LwPolylineVertex(v19));
                polyline2.Vertexes.Add(new LwPolylineVertex(v20));
                polyline2.Vertexes.Add(new LwPolylineVertex(v21));
                polyline2.Vertexes.Add(new LwPolylineVertex(v22));
                polyline2.Vertexes.Add(new LwPolylineVertex(v23));
                polyline2.Vertexes.Add(new LwPolylineVertex(v24));
                polyline2.Vertexes.Add(new LwPolylineVertex(v25));
                polyline2.Vertexes.Add(new LwPolylineVertex(v26));
                polyline2.Vertexes.Add(new LwPolylineVertex(v27));
                polyline2.Vertexes.Add(new LwPolylineVertex(v28));
                polyline2.Vertexes.Add(new LwPolylineVertex(v29));
                polyline2.Vertexes.Add(new LwPolylineVertex(v30_1));
                polyline2.Vertexes.Add(new LwPolylineVertex(v30));
                polyline2.Vertexes.Add(new LwPolylineVertex(v31));
                polyline2.Vertexes.Add(new LwPolylineVertex(v32));
                polyline2.Vertexes.Add(new LwPolylineVertex(v33));
                polyline2.Vertexes.Add(new LwPolylineVertex(v34));
                polyline2.Vertexes.Add(new LwPolylineVertex(v35));
                polyline2.Vertexes.Add(new LwPolylineVertex(v36));
                polyline2.Vertexes.Add(new LwPolylineVertex(v37));
                polyline2.Vertexes.Add(new LwPolylineVertex(v38));
                polyline2.Vertexes.Add(new LwPolylineVertex(v39));
                polyline2.Vertexes.Add(new LwPolylineVertex(D21));
                fun.PolyFill(dxf, polyline2, 0.3, contour);

                LwPolyline polyline3 = new LwPolyline();
                polyline3.Vertexes.Add(new LwPolylineVertex(D12));
                polyline3.Vertexes.Add(new LwPolylineVertex(D13));
                polyline3.Vertexes.Add(new LwPolylineVertex(D15));
                polyline3.Vertexes.Add(new LwPolylineVertex(D14));
                polyline3.Vertexes.Add(new LwPolylineVertex(D12));
                if (ctrap == 17)
                {
                    polyline3 = Pus.MirrorPolyline(polyline3, D1, D2);
                    D12 = polyline3.Vertexes[0].Position;
                    D13 = polyline3.Vertexes[1].Position;
                    D15 = polyline3.Vertexes[2].Position;
                    D14 = polyline3.Vertexes[3].Position;
                }
                fun.PolyFill(dxf, polyline3, 0.3, contour);

                LwPolyline polyline4 = new LwPolyline();
                polyline4.Vertexes.Add(new LwPolylineVertex(D18));
                polyline4.Vertexes.Add(new LwPolylineVertex(D16));
                polyline4.Vertexes.Add(new LwPolylineVertex(D17));
                polyline4.Vertexes.Add(new LwPolylineVertex(D19));
                if (ctrap == 17)
                {
                    polyline4 = Pus.MirrorPolyline(polyline4, D1, D2);
                    D18 = polyline4.Vertexes[0].Position;
                    D16 = polyline4.Vertexes[1].Position;
                    D17 = polyline4.Vertexes[2].Position;
                    D19 = polyline4.Vertexes[3].Position;
                }
                fun.PolyFill(dxf, polyline4, 0.3, contour);

                if (ctrap == 17)
                {
                    D20 = fun.mirrorpoint(D20, D1, D2);
                }
                LwPolyline polyline5 = new LwPolyline();
                polyline5.Vertexes.Add(new LwPolylineVertex(D10));
                polyline5.Vertexes.Add(new LwPolylineVertex(D20));
                fun.PolyFill(dxf, polyline5, 0.3, contour);

                if (ctrap == 17)
                {
                    D21 = fun.mirrorpoint(D21, D1, D2);
                }
                LwPolyline polyline6 = new LwPolyline();
                polyline6.Vertexes.Add(new LwPolylineVertex(D9));
                polyline6.Vertexes.Add(new LwPolylineVertex(D21));
                fun.PolyFill(dxf, polyline6, 0.3, contour);

                //第二部分
                //中心线
                Line line4 = new Line(D22, D23);
                line4.Layer = centre;
                line4.Linetype = Linetype.Center;
                line4.LinetypeScale = 5;
                dxf.AddEntity(line4);

                Line line3 = new Line(D22_1, D23_1);
                line3.Layer = centre;
                line3.Linetype = Linetype.Center;
                line3.LinetypeScale = 5;
                dxf.AddEntity(line3);

                LwPolyline polyline7 = new LwPolyline();
                polyline7.Vertexes.Add(new LwPolylineVertex(D24));
                polyline7.Vertexes.Add(new LwPolylineVertex(D25));
                polyline7.Vertexes.Add(new LwPolylineVertex(D26));
                polyline7.Vertexes.Add(new LwPolylineVertex(D27));
                polyline7.Vertexes.Add(new LwPolylineVertex(D24));
                if (ctrap == 17)
                {
                    polyline7 = Pus.MirrorPolyline(polyline7, D1, D2);
                    D24 = polyline7.Vertexes[0].Position;
                    D25 = polyline7.Vertexes[1].Position;
                    D26 = polyline7.Vertexes[2].Position;
                    D27 = polyline7.Vertexes[3].Position;
                }
                fun.PolyFill(dxf, polyline7, 0.3, contour);

                LwPolyline polyline8 = new LwPolyline();
                polyline8.Vertexes.Add(new LwPolylineVertex(D28));
                polyline8.Vertexes.Add(new LwPolylineVertex(D29));
                polyline8.Vertexes.Add(new LwPolylineVertex(D30));
                polyline8.Vertexes.Add(new LwPolylineVertex(D31));
                polyline8.Vertexes.Add(new LwPolylineVertex(D28));
                if (ctrap == 17)
                {
                    polyline8 = Pus.MirrorPolyline(polyline8, D1, D2);
                    D28 = polyline8.Vertexes[0].Position;
                    D29 = polyline8.Vertexes[1].Position;
                    D30 = polyline8.Vertexes[2].Position;
                    D31 = polyline8.Vertexes[3].Position;
                }
                fun.PolyFill(dxf, polyline8, 0.3, contour);

                LwPolyline polyline9 = new LwPolyline();
                polyline9.Vertexes.Add(new LwPolylineVertex(D32));
                polyline9.Vertexes.Add(new LwPolylineVertex(D33));
                polyline9.Vertexes.Add(new LwPolylineVertex(D35));
                polyline9.Vertexes.Add(new LwPolylineVertex(D34));
                polyline9.Vertexes.Add(new LwPolylineVertex(D32));
                if (ctrap == 17)
                {
                    polyline9 = Pus.MirrorPolyline(polyline9, D1, D2);
                    D32 = polyline9.Vertexes[0].Position;
                    D33 = polyline9.Vertexes[1].Position;
                    D35 = polyline9.Vertexes[2].Position;
                    D34 = polyline9.Vertexes[3].Position;
                }
                fun.PolyFill(dxf, polyline9, 0.3, contour);

                LwPolyline polyline10 = new LwPolyline();
                polyline10.Vertexes.Add(new LwPolylineVertex(D36));
                polyline10.Vertexes.Add(new LwPolylineVertex(D37));
                polyline10.Vertexes.Add(new LwPolylineVertex(D39));
                polyline10.Vertexes.Add(new LwPolylineVertex(D38));
                polyline10.Vertexes.Add(new LwPolylineVertex(D36));
                if (ctrap == 17)
                {
                    polyline10 = Pus.MirrorPolyline(polyline10, D1, D2);
                    D36 = polyline10.Vertexes[0].Position;
                    D37 = polyline10.Vertexes[1].Position;
                    D39 = polyline10.Vertexes[2].Position;
                    D38 = polyline10.Vertexes[3].Position;
                }
                fun.PolyFill(dxf, polyline10, 0.3, contour);

                LwPolyline polyline11 = new LwPolyline();
                polyline11.Vertexes.Add(new LwPolylineVertex(D44));
                polyline11.Vertexes.Add(new LwPolylineVertex(D46));
                if (ctrap == 17)
                {
                    polyline11 = Pus.MirrorPolyline(polyline11, D1, D2);
                    D44 = polyline11.Vertexes[0].Position;
                    D46 = polyline11.Vertexes[1].Position;
                }
                fun.PolyFill(dxf, polyline11, 0.3, contour);

                LwPolyline polyline12 = new LwPolyline();
                polyline12.Vertexes.Add(new LwPolylineVertex(D45));
                polyline12.Vertexes.Add(new LwPolylineVertex(D47));
                if (ctrap == 17)
                {
                    polyline12 = Pus.MirrorPolyline(polyline12, D1, D2);
                    D45 = polyline12.Vertexes[0].Position;
                    D47 = polyline12.Vertexes[1].Position;
                }
                fun.PolyFill(dxf, polyline12, 0.3, contour);

                LwPolyline polyline13 = new LwPolyline();
                polyline13.Vertexes.Add(new LwPolylineVertex(D40));
                polyline13.Vertexes.Add(new LwPolylineVertex(D41));
                polyline13.Vertexes.Add(new LwPolylineVertex(D42));
                polyline13.Vertexes.Add(new LwPolylineVertex(D43));
                polyline13.Vertexes.Add(new LwPolylineVertex(D40));
                if (ctrap == 17)
                {
                    polyline13 = Pus.MirrorPolyline(polyline13, D1, D2);
                    D40 = polyline13.Vertexes[0].Position;
                    D41 = polyline13.Vertexes[1].Position;
                    D42 = polyline13.Vertexes[2].Position;
                    D43 = polyline13.Vertexes[3].Position;
                }
                fun.PolyFill(dxf, polyline13, 0.3, contour);

                //虚线
                Circle circle1 = new Circle(D48, fun.CalDistance(v38, v39) / 2);
                circle1.Layer = refin;
                circle1.Linetype = Linetype.Dashed;
                circle1.LinetypeScale = 5;
                dxf.AddEntity(circle1);

                Circle circle2 = new Circle(D49, fun.CalDistance(v38, v39) / 5);
                circle2.Layer = refin;
                circle2.Linetype = Linetype.Dashed;
                circle2.LinetypeScale = 5;
                dxf.AddEntity(circle2);

                Line line5 = new Line(D48, D49);
                line5.Layer = refin;
                line5.Linetype = Linetype.Dashed;
                line5.LinetypeScale = 5;
                dxf.AddEntity(line5);

                if (ctrap == 17)
                {
                    D50 = fun.mirrorpoint(D50, D22, D23);
                    D51 = fun.mirrorpoint(D51, D22, D23);
                }
                Line line6 = new Line(D50, D51);
                line6.Layer = refin;
                line6.Linetype = Linetype.Dashed;
                line6.LinetypeScale = 5;
                dxf.AddEntity(line6);

                //标注定义
                double height = 2;
                double arrowsize = 1;
                double exline = 1;

                //D1标注
                if (ctrap == 16)
                {
                    //第一部分
                    //直线标注
                    //向上
                    fun.dimrot1(dxf, D3, D4, 0, h2, 1, height, arrowsize, exline, "l2=" + Math.Round(l2, 1), "", "");
                    fun.dimrot1(dxf, D10, D4, 0, h2, 1, height, arrowsize, exline, "l1=" + Math.Round(l1, 1), "", "");
                    //向左
                    fun.dimrot1(dxf, D11, D8, 90, l1, 1, height, arrowsize, exline, "h2=" + Math.Round(h2, 1), "", "");
                    fun.dimrot1(dxf, D1, D8, 90, l1 / 2, 1, height, arrowsize, exline, "h2=" + Math.Round(h2, 1), "", "");
                    fun.dimrot1(dxf, D1, D5, 90, l1 / 16, 1, height, arrowsize, exline, "h6=" + Math.Round(h6, 1), "", "");
                    //单引线箭头
                    Line line2 = new Line(v39, new Vector2(v39.X + l7, v39.Y));
                    line2.Layer = dimensioning;
                    dxf.AddEntity(line2);
                    fun.jt1(dxf, new Vector2(v39.X + l7 - 1, v39.Y), 90, h2 / 2, 1, "φd1=" + Math.Round(d1, 1), 2);
                    //单箭头标注
                    fun.jt1(dxf, v21, 60, h2 / 2, 1, "a=" + Math.Round(b, 1), 2);
                    //角度标注
                    fun.jdbz1(dxf, new Line(D6, new Vector2(D6.X + 0.1, D6.Y)), new Line(D5, fun.Polar(D5, a * pi / 180, 0.1)), l1 / 2, "α=" + a, height);

                    //第二部分
                    //直线标注
                    //向上
                    fun.dimrot1(dxf, D24, D22_1, 0, h3, 1, height, arrowsize, exline, "b3=" + Math.Round(b3, 1), "", "");
                    fun.dimrot1(dxf, D22_1, D25, 0, h3, 1, height, arrowsize, exline, "b1=" + Math.Round(b1, 1), "", "");
                    fun.dimrot1(dxf, D44, D22_1, 0, h3, 1, height, arrowsize, exline, "b4=" + Math.Round(b4, 1), "", "");
                    fun.dimrot1(dxf, D45, D22_1, 0, h3, 1, height, arrowsize, exline, "b2=" + Math.Round(b2, 1), "", "");
                    //向右
                    fun.dimrot1(dxf, D25, D23, -90, b2 / 2, 1, height, arrowsize, exline, "h3=" + Math.Round(h3, 1), "", "");
                    fun.dimrot1(dxf, D23, D42, -90, b2 / 2, 1, height, arrowsize, exline, "h4=" + Math.Round(h4, 1), "", "");
                }

                //D2标注
                if (ctrap == 17)
                {
                    //第一部分
                    //直线标注
                    //向下
                    fun.dimrot1(dxf, D3, D4, 180, h2, 1, height, arrowsize, exline, "l2=" + Math.Round(l2, 1), "", "");
                    fun.dimrot1(dxf, D10, D4, 180, h2, 1, height, arrowsize, exline, "l1=" + Math.Round(l1, 1), "", "");
                    //向左
                    fun.dimrot1(dxf, D11, D8, 90, l1, 1, height, arrowsize, exline, "h2=" + Math.Round(h2, 1), "", "");
                    fun.dimrot1(dxf, D1, D8, 90, l1 / 2, 1, height, arrowsize, exline, "h2=" + Math.Round(h2, 1), "", "");
                    fun.dimrot1(dxf, D1, D5, 90, l1 / 16, 1, height, arrowsize, exline, "h6=" + Math.Round(h6, 1), "", "");
                    //单引线箭头
                    Line line2 = new Line(v39, new Vector2(v39.X + l7, v39.Y));
                    line2.Layer = dimensioning;
                    dxf.AddEntity(line2);
                    fun.jt1(dxf, new Vector2(v39.X + l7 - 1, v39.Y), 90, h2 / 2, 1, "φd1=" + Math.Round(d1, 1), 2);
                    //单箭头标注
                    fun.jt1(dxf, v21, 60, h2 / 2, 1, "a=" + Math.Round(b, 1), 2);
                    //角度标注
                    fun.jdbz1(dxf, new Line(D6, new Vector2(D6.X + 0.1, D6.Y)), new Line(D5, fun.Polar(D5, -a * pi / 180, 0.1)), l1 / 2, "α=" + a, height);

                    //第二部分
                    //直线标注
                    //向下
                    fun.dimrot1(dxf, D24, D23_1, 180, h3, 1, height, arrowsize, exline, "b3=" + Math.Round(b3, 1), "", "");
                    fun.dimrot1(dxf, D23_1, D25, 180, h3, 1, height, arrowsize, exline, "b1=" + Math.Round(b1, 1), "", "");
                    fun.dimrot1(dxf, D44, D23_1, 180, h3, 1, height, arrowsize, exline, "b4=" + Math.Round(b4, 1), "", "");
                    fun.dimrot1(dxf, D45, D23_1, 180, h3, 1, height, arrowsize, exline, "b2=" + Math.Round(b2, 1), "", "");
                    //向右
                    fun.dimrot1(dxf, D25, D23, -90, b2 / 2, 1, height, arrowsize, exline, "h3=" + Math.Round(h3, 1), "", "");
                    fun.dimrot1(dxf, D23, D42, -90, b2 / 2, 1, height, arrowsize, exline, "h4=" + Math.Round(h4, 1), "", "");
                }
            }

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }


            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);

        }
    }
}
